Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -62,9 +62,17 @@ async def get_voices():
|
|
62 |
voices = await edge_tts.list_voices()
|
63 |
return {f"{v['ShortName']} - {v['Locale']} ({v['Gender']})": v['ShortName'] for v in voices}
|
64 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
async def generate_audio_with_voice_prefix(text_segment, default_voice, rate, pitch):
|
66 |
-
"""Generates audio for a text segment, handling permanent and temporary voice changes
|
67 |
-
|
68 |
# Define the voice map for reference
|
69 |
voice_map = {
|
70 |
"1F": ("en-GB-SoniaNeural", 25, 0),
|
@@ -112,6 +120,7 @@ async def generate_audio_with_voice_prefix(text_segment, default_voice, rate, pi
|
|
112 |
current_pitch += pitch_adj
|
113 |
current_rate += rate_adj
|
114 |
result.append(f"<perm>{prefix}P") # Mark as permanent change
|
|
|
115 |
elif pitch_modifier:
|
116 |
# Temporary pitch adjustment (e.g., "4V-10" or "4V+5")
|
117 |
pitch_adjustment = int(pitch_modifier)
|
@@ -158,6 +167,8 @@ async def generate_audio_with_voice_prefix(text_segment, default_voice, rate, pi
|
|
158 |
|
159 |
return None
|
160 |
|
|
|
|
|
161 |
async def process_transcript_line(line, default_voice, rate, pitch):
|
162 |
"""Processes a single transcript line with HH:MM:SS.milliseconds timestamp and quoted text segments."""
|
163 |
match = re.match(r'(\d{2}):(\d{2}):(\d{2}),(\d{3})\s+(.*)', line) # Modified timestamp regex
|
|
|
62 |
voices = await edge_tts.list_voices()
|
63 |
return {f"{v['ShortName']} - {v['Locale']} ({v['Gender']})": v['ShortName'] for v in voices}
|
64 |
|
65 |
+
|
66 |
+
## EDIT
|
67 |
+
import re
|
68 |
+
import tempfile
|
69 |
+
from pydub import AudioSegment
|
70 |
+
import asyncio
|
71 |
+
|
72 |
+
|
73 |
async def generate_audio_with_voice_prefix(text_segment, default_voice, rate, pitch):
|
74 |
+
"""Generates audio for a text segment, handling permanent and temporary voice changes."""
|
75 |
+
|
76 |
# Define the voice map for reference
|
77 |
voice_map = {
|
78 |
"1F": ("en-GB-SoniaNeural", 25, 0),
|
|
|
120 |
current_pitch += pitch_adj
|
121 |
current_rate += rate_adj
|
122 |
result.append(f"<perm>{prefix}P") # Mark as permanent change
|
123 |
+
temp_voice = None # Clear temporary voice changes
|
124 |
elif pitch_modifier:
|
125 |
# Temporary pitch adjustment (e.g., "4V-10" or "4V+5")
|
126 |
pitch_adjustment = int(pitch_modifier)
|
|
|
167 |
|
168 |
return None
|
169 |
|
170 |
+
### END EDIT
|
171 |
+
|
172 |
async def process_transcript_line(line, default_voice, rate, pitch):
|
173 |
"""Processes a single transcript line with HH:MM:SS.milliseconds timestamp and quoted text segments."""
|
174 |
match = re.match(r'(\d{2}):(\d{2}):(\d{2}),(\d{3})\s+(.*)', line) # Modified timestamp regex
|