File size: 988 Bytes
695fb87
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import requests

API_URL = "http://localhost:8000/api/v1/synthesize"

def synthesize_text(text: str, output_file: str):
    """
    Изпраща текст към API-то и запазва резултата като WAV файл.
    """
    print(f"Изпращане на заявка за: '{text}'...")
    
    response = requests.post(API_URL, json={
        "text": text,
        "voice_style": "F5",
        "speed": 1.6
    })
    
    if response.status_code == 200:
        with open(output_file, "wb") as f:
            f.write(response.content)
        print(f"✅ Аудиото е запазено успешно в: {output_file}")
    else:
        print(f"❌ Грешка: {response.status_code} - {response.text}")

if __name__ == "__main__":
    text_to_say = "Здравей! Това е тестов запис, създаден чрез новото Ani Voice API."
    output_filename = "test_api_output.wav"
    synthesize_text(text_to_say, output_filename)