
该存储库实现了语音到语音的级联管道,该管道由以下部分组成:
该管道提供了一种完全开放的模块化方法,重点是通过拥抱面轮上的变形金刚库可用的模型。该代码设计用于易于修改,我们已经支持特定于设备的和外部库的实现:
vad
stt
LLM
TTS
克隆存储库:
git clone https://github.com/huggingface/speech-to-speech.git
cd speech-to-speech使用UV安装所需的依赖项:
uv pip install -r requirements.txt对于Mac用户,请改用requirements_mac.txt文件:
uv pip install -r requirements_mac.txt如果要使用Melo TTS,也需要运行:
python -m unidic download管道可以通过两种方式运行:
在服务器上运行管道:
python s2s_pipeline.py --recv_host 0.0.0.0 --send_host 0.0.0.0在本地运行客户端以处理麦克风输入并接收生成的音频:
python listen_and_play.py --host < IP address of your server >python s2s_pipeline.py --local_mac_optimal_settings此设置:
--device mps将MPS用于所有型号。https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html
docker compose up
利用Torch汇编的小声说话和Parler-TTS。 Parler-TTS的使用允许音频输出流,从而降低了超级延迟:
python s2s_pipeline.py
--lm_model_name microsoft/Phi-3-mini-4k-instruct
--stt_compile_mode reduce-overhead
--tts_compile_mode default
--recv_host 0.0.0.0
--send_host 0.0.0.0 目前,捕获CUDA图的模式与流parler-tts不兼容( reduce-overhead , max-autotune )。
该管道目前支持英语,法语,西班牙语,中文,日语和韩语。
考虑了两种用例:
--language标志来执行语言设置,指定目标语言代码(默认为'en')。--language为“自动”。在这种情况下,Whisper检测到每个口语提示的语言,LLM的提示是“ Please reply to my message in ... ”,以确保响应使用被检测到的语言。请注意,您必须使用与目标语言兼容的STT和LLM检查点。对于STT部分,Parler-TTS尚未多语言(尽管该功能即将推出!?)。同时,您应该使用MELO(支持英语,法语,西班牙语,中文,日语和韩语)或CHAT-TTS。
用于自动语言检测:
python s2s_pipeline.py
--stt_model_name large-v3
--language auto
--mlx_lm_model_name mlx-community/Meta-Llama-3.1-8B-Instruct 或尤其是一种语言,在此示例中中文
python s2s_pipeline.py
--stt_model_name large-v3
--language zh
--mlx_lm_model_name mlx-community/Meta-Llama-3.1-8B-Instruct 用于自动语言检测:
python s2s_pipeline.py
--local_mac_optimal_settings
--device mps
--stt_model_name large-v3
--language auto
--mlx_lm_model_name mlx-community/Meta-Llama-3.1-8B-Instruct-4bit 或尤其是一种语言,在此示例中中文
python s2s_pipeline.py
--local_mac_optimal_settings
--device mps
--stt_model_name large-v3
--language zh
--mlx_lm_model_name mlx-community/Meta-Llama-3.1-8B-Instruct-4bit 注意:所有CLI参数的参考可以直接在参数类中或通过运行
python s2s_pipeline.py -h找到。
请参阅Modulearguments类。允许设置:
--device (如果希望每个零件在同一设备上运行)--mode local或server请参阅vadhandlerarguments类。尤其:
--thresh :触发语音活动检测的阈值值。--min_speech_ms :被视为语音的检测到的语音活动的最小持续时间。--min_silence_ms :静音间隔的最小长度,用于分割语音,平衡句子切割和减少延迟。对于文本,语言模型和语音文本的每个实现, model_name , torch_dtype和device都会暴露出来。用相应的前缀(例如stt , lm或tts指定目标管道部分,检查实现的参数类以获取更多详细信息)。
例如:
--lm_model_name google/gemma-2b-it可以使用零件的前缀 + _gen_ ,例如, --stt_gen_max_new_tokens 128设置模型生成方法的其他生成参数。如果尚未公开,可以将这些参数添加到管道部分的参数类中。
@misc { Silero VAD,
author = { Silero Team } ,
title = { Silero VAD: pre-trained enterprise-grade Voice Activity Detector (VAD), Number Detector and Language Classifier } ,
year = { 2021 } ,
publisher = { GitHub } ,
journal = { GitHub repository } ,
howpublished = { url{https://github.com/snakers4/silero-vad} } ,
commit = { insert_some_commit_here } ,
email = { hello @ silero.ai }
} @misc { gandhi2023distilwhisper ,
title = { Distil-Whisper: Robust Knowledge Distillation via Large-Scale Pseudo Labelling } ,
author = { Sanchit Gandhi and Patrick von Platen and Alexander M. Rush } ,
year = { 2023 } ,
eprint = { 2311.00430 } ,
archivePrefix = { arXiv } ,
primaryClass = { cs.CL }
} @misc { lacombe-etal-2024-parler-tts ,
author = { Yoach Lacombe and Vaibhav Srivastav and Sanchit Gandhi } ,
title = { Parler-TTS } ,
year = { 2024 } ,
publisher = { GitHub } ,
journal = { GitHub repository } ,
howpublished = { url{https://github.com/huggingface/parler-tts} }
}