Spaces:
Running
Running
Update voice.py
Browse files
voice.py
CHANGED
|
@@ -2,41 +2,56 @@ import edge_tts
|
|
| 2 |
import tempfile
|
| 3 |
import os
|
| 4 |
|
|
|
|
|
|
|
|
|
|
| 5 |
async def generate_audio(text: str, voice: str) -> str:
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
|
|
|
|
|
|
|
|
|
| 16 |
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
except Exception as e:
|
| 21 |
-
print(f"TTS Attempt {attempt+1} failed: {e}")
|
| 22 |
-
if attempt == 2:
|
| 23 |
-
raise e
|
| 24 |
-
return path
|
| 25 |
|
| 26 |
def get_voices():
|
| 27 |
-
|
|
|
|
|
|
|
|
|
|
| 28 |
return [
|
| 29 |
-
|
| 30 |
-
{"name": "
|
| 31 |
-
{"name": "
|
| 32 |
-
{"name": "
|
| 33 |
-
{"name": "
|
| 34 |
-
{"name": "
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
{"name": "
|
| 38 |
-
{"name": "
|
| 39 |
-
{"name": "
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
import tempfile
|
| 3 |
import os
|
| 4 |
|
| 5 |
+
# Use Microsoft Edge TTS - High quality neural voices
|
| 6 |
+
# Includes sexy, hot female voices with various accents
|
| 7 |
+
|
| 8 |
async def generate_audio(text: str, voice: str) -> str:
|
| 9 |
+
"""
|
| 10 |
+
Generate audio using Microsoft Edge TTS with high-quality neural voices
|
| 11 |
+
"""
|
| 12 |
+
try:
|
| 13 |
+
# Create a temporary file with .mp3 extension
|
| 14 |
+
fd, path = tempfile.mkstemp(suffix=".mp3")
|
| 15 |
+
os.close(fd)
|
| 16 |
+
|
| 17 |
+
# Generate speech using edge-tts
|
| 18 |
+
communicate = edge_tts.Communicate(text, voice)
|
| 19 |
+
await communicate.save(path)
|
| 20 |
+
|
| 21 |
+
return path
|
| 22 |
|
| 23 |
+
except Exception as e:
|
| 24 |
+
print(f"TTS Failed: {e}")
|
| 25 |
+
raise e
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
|
| 27 |
def get_voices():
|
| 28 |
+
"""
|
| 29 |
+
Return curated list of sexy, hot female voices
|
| 30 |
+
Featuring Microsoft's best neural voices with various styles
|
| 31 |
+
"""
|
| 32 |
return [
|
| 33 |
+
# ๐ฅ HOTTEST FEMALE VOICES - Sexy & Sultry ๐ฅ
|
| 34 |
+
{"name": "๐ Aria (Sexy US) - HOTTEST", "id": "en-US-AriaNeural"},
|
| 35 |
+
{"name": "๐ Jenny (Seductive US)", "id": "en-US-JennyNeural"},
|
| 36 |
+
{"name": "โจ Michelle (Flirty US)", "id": "en-US-MichelleNeural"},
|
| 37 |
+
{"name": "๐น Ashley (Sweet US)", "id": "en-US-AshleyNeural"},
|
| 38 |
+
{"name": "๐ Sara (Warm US)", "id": "en-US-SaraNeural"},
|
| 39 |
+
|
| 40 |
+
# ๐ฌ๐ง British Accent - Elegant & Sophisticated
|
| 41 |
+
{"name": "๐ Sonia (Sexy British)", "id": "en-GB-SoniaNeural"},
|
| 42 |
+
{"name": "๐ Libby (Cute British)", "id": "en-GB-LibbyNeural"},
|
| 43 |
+
{"name": "๐ Mia (Sweet British)", "id": "en-GB-MiaNeural"},
|
| 44 |
+
|
| 45 |
+
# ๐ฆ๐บ Australian Accent - Fun & Playful
|
| 46 |
+
{"name": "๐ด Natasha (Aussie Babe)", "id": "en-AU-NatashaNeural"},
|
| 47 |
+
{"name": "โ๏ธ Freya (Aussie Darling)", "id": "en-AU-FreyaNeural"},
|
| 48 |
+
|
| 49 |
+
# ๐ฎ๐ณ Indian Accent - Exotic & Beautiful
|
| 50 |
+
{"name": "๐บ Neerja (Indian Beauty)", "id": "en-IN-NeerjaNeural"},
|
| 51 |
+
|
| 52 |
+
# ๐จ๐ฆ Canadian - Friendly & Approachable
|
| 53 |
+
{"name": "๐ Clara (Canadian Cutie)", "id": "en-CA-ClaraNeural"},
|
| 54 |
+
|
| 55 |
+
# ๐ฎ๐ช Irish Accent - Charming
|
| 56 |
+
{"name": "โ๏ธ Emily (Irish Charm)", "id": "en-IE-EmilyNeural"},
|
| 57 |
+
]
|