Spaces:
Sleeping
Sleeping
u vioce
Browse files
app.py
CHANGED
|
@@ -23,8 +23,8 @@ generator = pipeline("text-generation",
|
|
| 23 |
# Async function to get voices
|
| 24 |
async def get_spanish_voices():
|
| 25 |
voices = await VoicesManager.create()
|
| 26 |
-
voice_male = [v for v in voices.voices if v['Gender'] == 'Male' and v['Locale'].startswith("
|
| 27 |
-
voice_female = [v for v in voices.voices if v['Gender'] == 'Female' and v['Locale'].startswith("
|
| 28 |
|
| 29 |
MALE_VOICE = random.choice(voice_male)['Name'] if voice_male else "en-US-GuyNeural"
|
| 30 |
FEMALE_VOICE = random.choice(voice_female)['Name'] if voice_female else "es-ES-ElviraNeural"
|
|
@@ -33,12 +33,14 @@ async def get_spanish_voices():
|
|
| 33 |
# Example usage (you must call this within async context or with asyncio.run)
|
| 34 |
MALE_VOICE, FEMALE_VOICE = asyncio.run(get_spanish_voices())
|
| 35 |
|
| 36 |
-
rate_male
|
| 37 |
-
pitch_male
|
| 38 |
-
pitch_female=
|
| 39 |
-
rate_female
|
| 40 |
rate_female_str = f"{rate_female:+d}%"
|
| 41 |
pitch_female_str = f"{pitch_female:+d}Hz"
|
|
|
|
|
|
|
| 42 |
|
| 43 |
KEY_TERMS = [
|
| 44 |
"model", "propose", "architecture", "performance", "accuracy", "experiment",
|
|
@@ -121,10 +123,12 @@ async def tts_edge_line_by_line(script):
|
|
| 121 |
speaker, content = line.split(':', 1)
|
| 122 |
speaker = speaker.strip().lower()
|
| 123 |
voice = MALE_VOICE if speaker == 'host' else FEMALE_VOICE
|
|
|
|
|
|
|
| 124 |
|
| 125 |
filename = f"segment_{uuid.uuid4().hex}.mp3"
|
| 126 |
filenames.append(filename)
|
| 127 |
-
tasks.append(generate_voice_line(content.strip(), voice, filename))
|
| 128 |
|
| 129 |
await asyncio.gather(*tasks)
|
| 130 |
|
|
|
|
| 23 |
# Async function to get voices
|
| 24 |
async def get_spanish_voices():
|
| 25 |
voices = await VoicesManager.create()
|
| 26 |
+
voice_male = [v for v in voices.voices if v['Gender'] == 'Male' and v['Locale'].startswith("en")]
|
| 27 |
+
voice_female = [v for v in voices.voices if v['Gender'] == 'Female' and v['Locale'].startswith("en")]
|
| 28 |
|
| 29 |
MALE_VOICE = random.choice(voice_male)['Name'] if voice_male else "en-US-GuyNeural"
|
| 30 |
FEMALE_VOICE = random.choice(voice_female)['Name'] if voice_female else "es-ES-ElviraNeural"
|
|
|
|
| 33 |
# Example usage (you must call this within async context or with asyncio.run)
|
| 34 |
MALE_VOICE, FEMALE_VOICE = asyncio.run(get_spanish_voices())
|
| 35 |
|
| 36 |
+
rate_male=-12
|
| 37 |
+
pitch_male=-10
|
| 38 |
+
pitch_female=5
|
| 39 |
+
rate_female=-15
|
| 40 |
rate_female_str = f"{rate_female:+d}%"
|
| 41 |
pitch_female_str = f"{pitch_female:+d}Hz"
|
| 42 |
+
rate_male_str = f"{rate_female:+d}%"
|
| 43 |
+
pitch_male_str = f"{pitch_female:+d}Hz"
|
| 44 |
|
| 45 |
KEY_TERMS = [
|
| 46 |
"model", "propose", "architecture", "performance", "accuracy", "experiment",
|
|
|
|
| 123 |
speaker, content = line.split(':', 1)
|
| 124 |
speaker = speaker.strip().lower()
|
| 125 |
voice = MALE_VOICE if speaker == 'host' else FEMALE_VOICE
|
| 126 |
+
pitch_str = pitch_male_str if speaker == 'host' else pitch_female_str
|
| 127 |
+
rate_str = rate_male_str if speaker == 'host' else rate_female_str
|
| 128 |
|
| 129 |
filename = f"segment_{uuid.uuid4().hex}.mp3"
|
| 130 |
filenames.append(filename)
|
| 131 |
+
tasks.append(generate_voice_line(content.strip(), voice, filename,rate=rate_str,pitch=pitch_str))
|
| 132 |
|
| 133 |
await asyncio.gather(*tasks)
|
| 134 |
|