File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed
Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Original file line number Diff line number Diff 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
Original file line number Diff line number Diff line change 33
44speech_file_path = Path (__file__ ).parent / "speech.mp3"
55client = OpenAI (api_key = "EMPTY" , base_url = "http://localhost:8082/v1" )
6+
67with 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 可以直接通过播放器进行流式的 实时播放
You can’t perform that action at this time.
0 commit comments