Spaces:
Running
Running
| import urllib.request | |
| import json | |
| url = "http://localhost:3900/v1/audio/speech" | |
| data = { | |
| "model": "omnivoice", | |
| "input": "Xin chào! Đây là một đoạn âm thanh thử nghiệm được tạo ra tự động từ OmniVoice Studio. Chất lượng giọng đọc rất tự nhiên và hỗ trợ tiếng Việt rất tốt.", | |
| "voice": "alloy", | |
| "response_format": "wav" | |
| } | |
| req = urllib.request.Request(url, data=json.dumps(data).encode("utf-8"), headers={"Content-Type": "application/json"}) | |
| with urllib.request.urlopen(req) as response: | |
| with open("sample.wav", "wb") as f: | |
| f.write(response.read()) | |
| print("Audio generated successfully at sample.wav") | |