Spaces:
Running
Running
File size: 1,693 Bytes
50876ef | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | #!/usr/bin/env python3
"""
Generate voice demo MP3 files for the 3 voice options.
Run this script once to create static demo files.
"""
import requests
import os
API_URL = "https://api.microfunnel.online/api/v1/voice/synthesize"
OUTPUT_DIR = r"d:\MicroFunnel Studio\frontend\public\voice-demos"
VOICES = [
{
"id": "professional_male",
"text": "Здравствуйте! Я ваш менеджер. Готов помочь найти решение для бизнеса."
},
{
"id": "friendly_male",
"text": "Привет! Рад что написали. Давайте разберёмся что вам нужно!"
},
{
"id": "professional_female",
"text": "Добрый день! Спасибо за интерес. Расскажу подробнее."
}
]
def main():
os.makedirs(OUTPUT_DIR, exist_ok=True)
for voice in VOICES:
print(f"Generating {voice['id']}...")
try:
response = requests.post(
API_URL,
json={
"text": voice["text"],
"voice": voice["id"]
},
timeout=60
)
if response.status_code == 200:
output_path = os.path.join(OUTPUT_DIR, f"{voice['id']}.mp3")
with open(output_path, "wb") as f:
f.write(response.content)
print(f" OK: Saved to {output_path}")
else:
print(f" ERROR: {response.status_code}")
except Exception as e:
print(f" EXCEPTION: {e}")
if __name__ == "__main__":
main()
|