2025-03-21 18:03:09 +00:00
|
|
|
import base64
|
|
|
|
import json
|
|
|
|
|
2025-04-04 16:50:46 -06:00
|
|
|
import requests
|
|
|
|
|
2025-05-28 14:53:00 +00:00
|
|
|
text = """奶酪芝士很浓郁!臭豆腐芝士有争议?陈年奶酪价格昂贵。"""
|
2025-03-21 18:03:09 +00:00
|
|
|
|
|
|
|
|
2025-04-04 16:58:07 -06:00
|
|
|
Type = "wav"
|
2025-03-21 18:03:09 +00:00
|
|
|
|
|
|
|
response = requests.post(
|
|
|
|
"http://localhost:8880/v1/audio/speech",
|
|
|
|
json={
|
|
|
|
"model": "kokoro",
|
|
|
|
"input": text,
|
2025-05-28 14:53:00 +00:00
|
|
|
"voice": "zf_xiaobei",
|
2025-03-21 18:03:09 +00:00
|
|
|
"speed": 1.0,
|
|
|
|
"response_format": Type,
|
|
|
|
"stream": False,
|
|
|
|
},
|
2025-04-04 16:58:07 -06:00
|
|
|
stream=True,
|
2025-03-21 18:03:09 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
with open(f"outputnostreammoney.{Type}", "wb") as f:
|
|
|
|
f.write(response.content)
|