File size: 693 Bytes
a90990e
bbe9b6e
41d6250
1180f3c
19401eb
 
 
58f6d57
 
41d6250
 
 
 
a90990e
41d6250
 
 
 
58fd969
58f6d57
41d6250
58f6d57
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import numpy as np
import torchaudio
import logging

# Set up logging
logging.basicConfig(level=logging.DEBUG)

def synthesize_speech(text):
    try:
        # Generate a simple sine wave for testing
        sr = 16000
        t = np.linspace(0, 1, sr)
        waveform = 0.5 * np.sin(2 * np.pi * 440 * t).astype(np.float32)

        # Save the sine wave to a file
        file_path = "/tmp/output.wav"
        torchaudio.save(file_path, torch.tensor(waveform).unsqueeze(0), sr)
        logging.info(f"Test audio file saved successfully at {file_path}.")
        return file_path
    except Exception as e:
        logging.error(f"Error during test audio generation: {e}")
        return None