Skip to content

Commit 4cc45ee

Browse files
committed
update tts stream
1 parent fe4f9dd commit 4cc45ee

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

gpt_server/script/config_example.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,3 +130,15 @@ models:
130130
workers:
131131
- gpus:
132132
- 2
133+
- tts:
134+
# TTS 模型的配置方式
135+
alias: null
136+
enable: true
137+
model_config:
138+
model_name_or_path: /home/dev/model/SparkAudio/Spark-TTS-0___5B/
139+
model_type: spark_tts
140+
work_mode: vllm
141+
device: gpu
142+
workers:
143+
- gpus:
144+
- 6

tests/test_openai_tts_stream.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@
33

44
speech_file_path = Path(__file__).parent / "speech.mp3"
55
client = OpenAI(api_key="EMPTY", base_url="http://localhost:8082/v1")
6+
67
with client.audio.speech.with_streaming_response.create(
78
model="tts",
89
voice="新闻联播女声", # 暂时仅支持 新闻联播女声
910
input="本期节目主要内容: 一.习近平在参加北京市区人大代表换届选举投票时强调 不断发展全过程人民民主 加强选举全过程监督",
1011
) as response:
11-
response.stream_to_file(speech_file_path)
12+
with open(speech_file_path, mode="wb") as f:
13+
for chunk in response.iter_bytes():
14+
f.write(chunk) # 这个 chunk 可以直接通过播放器进行流式的 实时播放

0 commit comments

Comments
 (0)