drewThomasson
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -10,12 +10,18 @@ tts = TTS().from_pretrained("AstraMindAI/xttsv2", gpt_model="AstraMindAI/xtts2-g
|
|
10 |
|
11 |
# Function to generate speech with enhancement
|
12 |
def generate_speech_with_enhancement(text, speaker_audio):
|
13 |
-
|
|
|
14 |
|
|
|
|
|
15 |
# Read the speaker audio file
|
16 |
-
|
17 |
-
|
18 |
-
|
|
|
|
|
|
|
19 |
# Create an instance of AudioPreprocessingConfig for enhancement
|
20 |
audio_config = AudioPreprocessingConfig(
|
21 |
normalize=True,
|
@@ -47,12 +53,18 @@ def generate_speech_with_enhancement(text, speaker_audio):
|
|
47 |
|
48 |
# Function to generate speech without enhancement
|
49 |
def generate_speech_without_enhancement(text, speaker_audio):
|
50 |
-
|
|
|
51 |
|
|
|
|
|
52 |
# Read the speaker audio file
|
53 |
-
|
54 |
-
|
55 |
-
|
|
|
|
|
|
|
56 |
# Create the TTS request without enhancement
|
57 |
request = TTSRequest(
|
58 |
text=text,
|
|
|
10 |
|
11 |
# Function to generate speech with enhancement
|
12 |
def generate_speech_with_enhancement(text, speaker_audio):
|
13 |
+
if not speaker_audio:
|
14 |
+
return None, "Error: No speaker audio provided."
|
15 |
|
16 |
+
start_time = time.time() # Start timing
|
17 |
+
|
18 |
# Read the speaker audio file
|
19 |
+
try:
|
20 |
+
with open(speaker_audio, "rb") as f:
|
21 |
+
audio_data = f.read()
|
22 |
+
except Exception as e:
|
23 |
+
return None, f"Error reading speaker audio: {e}"
|
24 |
+
|
25 |
# Create an instance of AudioPreprocessingConfig for enhancement
|
26 |
audio_config = AudioPreprocessingConfig(
|
27 |
normalize=True,
|
|
|
53 |
|
54 |
# Function to generate speech without enhancement
|
55 |
def generate_speech_without_enhancement(text, speaker_audio):
|
56 |
+
if not speaker_audio:
|
57 |
+
return None, "Error: No speaker audio provided."
|
58 |
|
59 |
+
start_time = time.time() # Start timing
|
60 |
+
|
61 |
# Read the speaker audio file
|
62 |
+
try:
|
63 |
+
with open(speaker_audio, "rb") as f:
|
64 |
+
audio_data = f.read()
|
65 |
+
except Exception as e:
|
66 |
+
return None, f"Error reading speaker audio: {e}"
|
67 |
+
|
68 |
# Create the TTS request without enhancement
|
69 |
request = TTSRequest(
|
70 |
text=text,
|