speech-to-speech 0.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. speech_to_speech-0.2.0/LICENSE +201 -0
  2. speech_to_speech-0.2.0/MANIFEST.in +4 -0
  3. speech_to_speech-0.2.0/PKG-INFO +426 -0
  4. speech_to_speech-0.2.0/README.md +359 -0
  5. speech_to_speech-0.2.0/pyproject.toml +130 -0
  6. speech_to_speech-0.2.0/setup.cfg +4 -0
  7. speech_to_speech-0.2.0/src/speech_to_speech/LLM/__init__.py +0 -0
  8. speech_to_speech-0.2.0/src/speech_to_speech/LLM/chat.py +420 -0
  9. speech_to_speech-0.2.0/src/speech_to_speech/LLM/language_model.py +746 -0
  10. speech_to_speech-0.2.0/src/speech_to_speech/LLM/lm_output_processor.py +85 -0
  11. speech_to_speech-0.2.0/src/speech_to_speech/LLM/openai_api_language_model.py +313 -0
  12. speech_to_speech-0.2.0/src/speech_to_speech/LLM/tool_call/function_call.py +285 -0
  13. speech_to_speech-0.2.0/src/speech_to_speech/LLM/tool_call/function_tool.py +34 -0
  14. speech_to_speech-0.2.0/src/speech_to_speech/LLM/tool_call/signature_from_schema.py +108 -0
  15. speech_to_speech-0.2.0/src/speech_to_speech/LLM/tool_call/tool_prompt.py +93 -0
  16. speech_to_speech-0.2.0/src/speech_to_speech/LLM/utils.py +75 -0
  17. speech_to_speech-0.2.0/src/speech_to_speech/LLM/voice_prompt.py +70 -0
  18. speech_to_speech-0.2.0/src/speech_to_speech/STT/__init__.py +1 -0
  19. speech_to_speech-0.2.0/src/speech_to_speech/STT/faster_whisper_handler.py +63 -0
  20. speech_to_speech-0.2.0/src/speech_to_speech/STT/lightning_whisper_mlx_handler.py +97 -0
  21. speech_to_speech-0.2.0/src/speech_to_speech/STT/mlx_audio_whisper_handler.py +149 -0
  22. speech_to_speech-0.2.0/src/speech_to_speech/STT/paraformer_handler.py +61 -0
  23. speech_to_speech-0.2.0/src/speech_to_speech/STT/parakeet_tdt_handler.py +503 -0
  24. speech_to_speech-0.2.0/src/speech_to_speech/STT/smart_progressive_streaming.py +343 -0
  25. speech_to_speech-0.2.0/src/speech_to_speech/STT/transcription_notifier.py +77 -0
  26. speech_to_speech-0.2.0/src/speech_to_speech/STT/whisper_stt_handler.py +141 -0
  27. speech_to_speech-0.2.0/src/speech_to_speech/TTS/__init__.py +1 -0
  28. speech_to_speech-0.2.0/src/speech_to_speech/TTS/chatTTS_handler.py +101 -0
  29. speech_to_speech-0.2.0/src/speech_to_speech/TTS/facebookmms_handler.py +194 -0
  30. speech_to_speech-0.2.0/src/speech_to_speech/TTS/kokoro_handler.py +400 -0
  31. speech_to_speech-0.2.0/src/speech_to_speech/TTS/pocket_tts_handler.py +209 -0
  32. speech_to_speech-0.2.0/src/speech_to_speech/TTS/qwen3_tts_handler.py +788 -0
  33. speech_to_speech-0.2.0/src/speech_to_speech/TTS/ref_audio.wav +0 -0
  34. speech_to_speech-0.2.0/src/speech_to_speech/VAD/__init__.py +1 -0
  35. speech_to_speech-0.2.0/src/speech_to_speech/VAD/vad_handler.py +308 -0
  36. speech_to_speech-0.2.0/src/speech_to_speech/VAD/vad_iterator.py +160 -0
  37. speech_to_speech-0.2.0/src/speech_to_speech/__init__.py +3 -0
  38. speech_to_speech-0.2.0/src/speech_to_speech/api/__init__.py +0 -0
  39. speech_to_speech-0.2.0/src/speech_to_speech/api/openai_realtime/__init__.py +0 -0
  40. speech_to_speech-0.2.0/src/speech_to_speech/api/openai_realtime/handlers/__init__.py +11 -0
  41. speech_to_speech-0.2.0/src/speech_to_speech/api/openai_realtime/handlers/audio.py +164 -0
  42. speech_to_speech-0.2.0/src/speech_to_speech/api/openai_realtime/handlers/base.py +47 -0
  43. speech_to_speech-0.2.0/src/speech_to_speech/api/openai_realtime/handlers/conversation.py +131 -0
  44. speech_to_speech-0.2.0/src/speech_to_speech/api/openai_realtime/handlers/response.py +255 -0
  45. speech_to_speech-0.2.0/src/speech_to_speech/api/openai_realtime/handlers/session.py +62 -0
  46. speech_to_speech-0.2.0/src/speech_to_speech/api/openai_realtime/runtime_config.py +81 -0
  47. speech_to_speech-0.2.0/src/speech_to_speech/api/openai_realtime/server.py +88 -0
  48. speech_to_speech-0.2.0/src/speech_to_speech/api/openai_realtime/service.py +337 -0
  49. speech_to_speech-0.2.0/src/speech_to_speech/api/openai_realtime/utils.py +12 -0
  50. speech_to_speech-0.2.0/src/speech_to_speech/api/openai_realtime/websocket_router.py +346 -0
  51. speech_to_speech-0.2.0/src/speech_to_speech/arguments_classes/__init__.py +1 -0
  52. speech_to_speech-0.2.0/src/speech_to_speech/arguments_classes/chat_tts_arguments.py +19 -0
  53. speech_to_speech-0.2.0/src/speech_to_speech/arguments_classes/facebookmms_tts_arguments.py +21 -0
  54. speech_to_speech-0.2.0/src/speech_to_speech/arguments_classes/faster_whisper_stt_arguments.py +54 -0
  55. speech_to_speech-0.2.0/src/speech_to_speech/arguments_classes/kokoro_tts_arguments.py +38 -0
  56. speech_to_speech-0.2.0/src/speech_to_speech/arguments_classes/language_model_arguments.py +79 -0
  57. speech_to_speech-0.2.0/src/speech_to_speech/arguments_classes/mlx_audio_whisper_arguments.py +15 -0
  58. speech_to_speech-0.2.0/src/speech_to_speech/arguments_classes/module_arguments.py +58 -0
  59. speech_to_speech-0.2.0/src/speech_to_speech/arguments_classes/open_api_language_model_arguments.py +69 -0
  60. speech_to_speech-0.2.0/src/speech_to_speech/arguments_classes/paraformer_stt_arguments.py +15 -0
  61. speech_to_speech-0.2.0/src/speech_to_speech/arguments_classes/parakeet_tdt_arguments.py +39 -0
  62. speech_to_speech-0.2.0/src/speech_to_speech/arguments_classes/pocket_tts_arguments.py +31 -0
  63. speech_to_speech-0.2.0/src/speech_to_speech/arguments_classes/qwen3_tts_arguments.py +94 -0
  64. speech_to_speech-0.2.0/src/speech_to_speech/arguments_classes/socket_receiver_arguments.py +20 -0
  65. speech_to_speech-0.2.0/src/speech_to_speech/arguments_classes/socket_sender_arguments.py +16 -0
  66. speech_to_speech-0.2.0/src/speech_to_speech/arguments_classes/vad_arguments.py +57 -0
  67. speech_to_speech-0.2.0/src/speech_to_speech/arguments_classes/websocket_streamer_arguments.py +16 -0
  68. speech_to_speech-0.2.0/src/speech_to_speech/arguments_classes/whisper_stt_arguments.py +52 -0
  69. speech_to_speech-0.2.0/src/speech_to_speech/baseHandler.py +106 -0
  70. speech_to_speech-0.2.0/src/speech_to_speech/connections/__init__.py +1 -0
  71. speech_to_speech-0.2.0/src/speech_to_speech/connections/local_audio_streamer.py +71 -0
  72. speech_to_speech-0.2.0/src/speech_to_speech/connections/socket_receiver.py +85 -0
  73. speech_to_speech-0.2.0/src/speech_to_speech/connections/socket_sender.py +69 -0
  74. speech_to_speech-0.2.0/src/speech_to_speech/connections/websocket_streamer.py +238 -0
  75. speech_to_speech-0.2.0/src/speech_to_speech/pipeline/__init__.py +55 -0
  76. speech_to_speech-0.2.0/src/speech_to_speech/pipeline/cancel_scope.py +53 -0
  77. speech_to_speech-0.2.0/src/speech_to_speech/pipeline/control.py +22 -0
  78. speech_to_speech-0.2.0/src/speech_to_speech/pipeline/events.py +67 -0
  79. speech_to_speech-0.2.0/src/speech_to_speech/pipeline/handler_types.py +43 -0
  80. speech_to_speech-0.2.0/src/speech_to_speech/pipeline/messages.py +132 -0
  81. speech_to_speech-0.2.0/src/speech_to_speech/pipeline/queue_types.py +45 -0
  82. speech_to_speech-0.2.0/src/speech_to_speech/s2s_pipeline.py +767 -0
  83. speech_to_speech-0.2.0/src/speech_to_speech/utils/__init__.py +0 -0
  84. speech_to_speech-0.2.0/src/speech_to_speech/utils/mlx_lock.py +77 -0
  85. speech_to_speech-0.2.0/src/speech_to_speech/utils/thread_manager.py +39 -0
  86. speech_to_speech-0.2.0/src/speech_to_speech/utils/utils.py +24 -0
  87. speech_to_speech-0.2.0/src/speech_to_speech.egg-info/PKG-INFO +426 -0
  88. speech_to_speech-0.2.0/src/speech_to_speech.egg-info/SOURCES.txt +90 -0
  89. speech_to_speech-0.2.0/src/speech_to_speech.egg-info/dependency_links.txt +1 -0
  90. speech_to_speech-0.2.0/src/speech_to_speech.egg-info/entry_points.txt +2 -0
  91. speech_to_speech-0.2.0/src/speech_to_speech.egg-info/requires.txt +66 -0
  92. speech_to_speech-0.2.0/src/speech_to_speech.egg-info/top_level.txt +1 -0
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [2024] [The HuggingFace Inc. team]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,4 @@
1
+ prune tests
2
+ global-exclude __pycache__
3
+ global-exclude *.py[cod]
4
+ global-exclude .DS_Store
@@ -0,0 +1,426 @@
1
+ Metadata-Version: 2.4
2
+ Name: speech-to-speech
3
+ Version: 0.2.0
4
+ Summary: Low-latency speech-to-speech pipeline
5
+ Author: Hugging Face
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/huggingface/speech-to-speech
8
+ Project-URL: Repository, https://github.com/huggingface/speech-to-speech
9
+ Project-URL: Issues, https://github.com/huggingface/speech-to-speech/issues
10
+ Keywords: speech-to-speech,voice-agents,speech-recognition,text-to-speech,openai
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Topic :: Multimedia :: Sound/Audio :: Speech
18
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
19
+ Requires-Python: >=3.10
20
+ Description-Content-Type: text/markdown
21
+ License-File: LICENSE
22
+ Requires-Dist: fastapi>=0.115.0
23
+ Requires-Dist: httpx>=0.28.0
24
+ Requires-Dist: nltk==3.9.1
25
+ Requires-Dist: numpy>=1.26.0
26
+ Requires-Dist: openai==2.28.0
27
+ Requires-Dist: pydantic>=2.0
28
+ Requires-Dist: rich>=13.0
29
+ Requires-Dist: scipy>=1.10.0
30
+ Requires-Dist: sounddevice>=0.5.0
31
+ Requires-Dist: soundfile>=0.13.0; platform_system == "Darwin"
32
+ Requires-Dist: torch==2.11.0; platform_system == "Darwin"
33
+ Requires-Dist: torch>=2.4.0; platform_system != "Darwin"
34
+ Requires-Dist: transformers>=4.57.0
35
+ Requires-Dist: uvicorn>=0.30.0
36
+ Requires-Dist: nano-parakeet>=0.2.0; platform_system != "Darwin"
37
+ Requires-Dist: faster-qwen3-tts>=0.2.6; platform_system != "Darwin"
38
+ Requires-Dist: mlx-audio<0.5.0,>=0.4.0; platform_system == "Darwin"
39
+ Requires-Dist: misaki>=0.9.4; platform_system == "Darwin"
40
+ Requires-Dist: espeakng-loader>=0.2.4; platform_system == "Darwin"
41
+ Requires-Dist: spacy>=3.8.4; platform_system == "Darwin"
42
+ Requires-Dist: phonemizer-fork>=3.3.2; platform_system == "Darwin"
43
+ Provides-Extra: chattts
44
+ Requires-Dist: ChatTTS>=0.1.1; extra == "chattts"
45
+ Provides-Extra: facebook-mms
46
+ Requires-Dist: transformers>=4.57.0; extra == "facebook-mms"
47
+ Provides-Extra: faster-whisper
48
+ Requires-Dist: faster-whisper>=1.0.3; extra == "faster-whisper"
49
+ Provides-Extra: kokoro
50
+ Requires-Dist: kokoro>=0.9.2; platform_system != "Darwin" and extra == "kokoro"
51
+ Provides-Extra: language-detection
52
+ Requires-Dist: lingua-language-detector>=2.0.2; extra == "language-detection"
53
+ Provides-Extra: mlx-lm
54
+ Requires-Dist: mlx-lm>=0.14.0; platform_system == "Darwin" and extra == "mlx-lm"
55
+ Requires-Dist: mlx-vlm==0.4.1; platform_system == "Darwin" and extra == "mlx-lm"
56
+ Provides-Extra: paraformer
57
+ Requires-Dist: funasr>=1.1.6; extra == "paraformer"
58
+ Requires-Dist: modelscope>=1.17.1; extra == "paraformer"
59
+ Requires-Dist: onnxruntime<1.24; python_version < "3.11" and extra == "paraformer"
60
+ Provides-Extra: pocket
61
+ Requires-Dist: pocket-tts>=0.1.0; extra == "pocket"
62
+ Provides-Extra: websocket
63
+ Requires-Dist: websockets>=12.0; extra == "websocket"
64
+ Provides-Extra: whisper-mlx
65
+ Requires-Dist: lightning-whisper-mlx>=0.0.10; platform_system == "Darwin" and extra == "whisper-mlx"
66
+ Dynamic: license-file
67
+
68
+ <div align="center">
69
+ <div>&nbsp;</div>
70
+ <img src="https://raw.githubusercontent.com/huggingface/speech-to-speech/main/logo.png" width="600"/>
71
+ </div>
72
+
73
+ # Speech To Speech: Build local voice agents with open-source models
74
+
75
+ ## 📖 Quick Index
76
+ * [Approach](#approach)
77
+ - [Structure](#structure)
78
+ - [Modularity](#modularity)
79
+ * [Setup](#setup)
80
+ * [Usage](#usage)
81
+ - [Realtime approach](#realtime-approach)
82
+ - [Server/Client approach](#serverclient-approach)
83
+ - [WebSocket approach](#websocket-approach)
84
+ - [Local approach](#local-approach-running-on-mac)
85
+ - [Docker Server approach](#docker-server)
86
+ * [Command-line usage](#command-line-usage)
87
+ - [Model parameters](#model-parameters)
88
+ - [Generation parameters](#generation-parameters)
89
+ - [Notable parameters](#notable-parameters)
90
+
91
+ ## Approach
92
+
93
+ ### Structure
94
+ This repository implements a speech-to-speech cascaded pipeline consisting of the following parts:
95
+ 1. **Voice Activity Detection (VAD)**
96
+ 2. **Speech to Text (STT)**
97
+ 3. **Language Model (LM)**
98
+ 4. **Text to Speech (TTS)**
99
+
100
+ ### Modularity
101
+ The pipeline provides a fully open and modular approach, with a focus on leveraging models available through the Transformers library on the Hugging Face hub. The code is designed for easy modification, and we already support device-specific and external library implementations:
102
+
103
+ **VAD**
104
+ - [Silero VAD v5](https://github.com/snakers4/silero-vad)
105
+
106
+ **STT**
107
+ - Any [Whisper](https://huggingface.co/docs/transformers/en/model_doc/whisper) model checkpoint on the Hugging Face Hub through Transformers 🤗, including [whisper-large-v3](https://huggingface.co/openai/whisper-large-v3) and [distil-large-v3](https://huggingface.co/distil-whisper/distil-large-v3)
108
+ - [Lightning Whisper MLX](https://github.com/mustafaaljadery/lightning-whisper-mlx?tab=readme-ov-file#lightning-whisper-mlx)
109
+ - [MLX Audio Whisper](https://github.com/huggingface/mlx-audio) - Fast Whisper inference on Apple Silicon
110
+ - [Parakeet TDT](https://huggingface.co/nvidia/parakeet-tdt-1.1b) - Real-time streaming STT with sub-100ms latency on Apple Silicon (CUDA/CPU via nano-parakeet, no NeMo)
111
+ - [Paraformer - FunASR](https://github.com/modelscope/FunASR)
112
+
113
+ **LLM**
114
+ - Any instruction-following model on the [Hugging Face Hub](https://huggingface.co/models?pipeline_tag=text-generation&sort=trending) via Transformers 🤗
115
+ - [mlx-lm](https://github.com/ml-explore/mlx-examples/blob/main/llms/README.md)
116
+ - [OpenAI API](https://platform.openai.com/docs/quickstart)
117
+
118
+ **TTS**
119
+ - [ChatTTS](https://github.com/2noise/ChatTTS?tab=readme-ov-file)
120
+ - [Pocket TTS](https://github.com/kyutai-labs/pocket-tts) - Streaming TTS with voice cloning from Kyutai Labs
121
+ - [Kokoro-82M](https://huggingface.co/hexgrad/Kokoro-82M) - Fast and high-quality TTS optimized for Apple Silicon
122
+ - [Qwen3-TTS](https://huggingface.co/Qwen/Qwen3-TTS-12Hz-1.7B-CustomVoice)
123
+
124
+ ## Setup
125
+
126
+ Install the default package from PyPI:
127
+ ```bash
128
+ pip install speech-to-speech
129
+ ```
130
+
131
+ The default install is scoped to the standard realtime voice-agent path:
132
+ - Parakeet TDT for STT
133
+ - OpenAI-compatible API for the language model
134
+ - Qwen3-TTS for speech output
135
+ - local audio and realtime server modes
136
+
137
+ Optional backends are installed with extras:
138
+ ```bash
139
+ pip install "speech-to-speech[kokoro]"
140
+ pip install "speech-to-speech[pocket]"
141
+ pip install "speech-to-speech[faster-whisper]"
142
+ pip install "speech-to-speech[paraformer]"
143
+ pip install "speech-to-speech[mlx-lm]"
144
+ pip install "speech-to-speech[websocket]"
145
+ ```
146
+
147
+ Deprecated model implementations, including MeloTTS, live in [`archive/`](./archive) and are no longer wired into the CLI.
148
+
149
+ For development from source:
150
+ ```bash
151
+ git clone https://github.com/huggingface/speech-to-speech.git
152
+ cd speech-to-speech
153
+ uv sync
154
+ ```
155
+
156
+ This installs the `speech_to_speech` package in editable mode and makes the `speech-to-speech` CLI command available. The project uses a single `pyproject.toml` with platform markers, so macOS and non-macOS dependencies are resolved automatically from one file.
157
+
158
+ **Note on DeepFilterNet:** DeepFilterNet (used for optional audio enhancement in VAD) requires `numpy<2` and conflicts with Pocket TTS, which requires `numpy>=2`. Install DeepFilterNet manually only in environments where you are not using Pocket TTS.
159
+
160
+
161
+ ## Usage
162
+
163
+ The default CLI is equivalent to a realtime Parakeet + OpenAI-compatible LLM + Qwen3-TTS setup. It uses `OPENAI_API_KEY` from the environment unless `--open_api_api_key` is provided:
164
+ ```bash
165
+ speech-to-speech
166
+ ```
167
+
168
+ The pipeline can be run in four ways:
169
+ - **Realtime approach**: Models run locally or on a server, and an OpenAI Realtime-compatible WebSocket API is exposed for another app.
170
+ - **Server/Client approach**: Models run on a server, and audio input/output are streamed from a client using TCP sockets.
171
+ - **WebSocket approach**: Models run on a server, and audio input/output are streamed from a client using WebSockets.
172
+ - **Local approach**: Runs locally.
173
+
174
+ ### Recommended setup
175
+
176
+ ### Realtime Approach
177
+
178
+ The default realtime setup uses `--llm open_api`, so it needs an OpenAI API key. Export `OPENAI_API_KEY` before launching, or pass `--open_api_api_key` explicitly. For a deployed OpenAI-compatible LLM, also set `--open_api_base_url`.
179
+
180
+ ```bash
181
+ export OPENAI_API_KEY=...
182
+ ```
183
+
184
+ The default mode starts the OpenAI Realtime-compatible server:
185
+ ```bash
186
+ speech-to-speech
187
+ ```
188
+
189
+ This is equivalent to:
190
+ ```bash
191
+ speech-to-speech \
192
+ --thresh 0.6 \
193
+ --stt parakeet-tdt \
194
+ --llm open_api \
195
+ --tts qwen3 \
196
+ --qwen3_tts_model_name Qwen/Qwen3-TTS-12Hz-1.7B-CustomVoice \
197
+ --qwen3_tts_speaker Aiden \
198
+ --qwen3_tts_language auto \
199
+ --qwen3_tts_non_streaming_mode True \
200
+ --qwen3_tts_mlx_quantization 6bit \
201
+ --open_api_model_name gpt-5.4-mini \
202
+ --open_api_chat_size 30 \
203
+ --open_api_stream \
204
+ --enable_live_transcription \
205
+ --mode realtime
206
+ ```
207
+
208
+ ### Server/Client Approach
209
+
210
+ 1. Run the pipeline on the server:
211
+ ```bash
212
+ speech-to-speech --recv_host 0.0.0.0 --send_host 0.0.0.0
213
+ ```
214
+
215
+ 2. Run the client locally to handle microphone input and receive generated audio:
216
+ ```bash
217
+ python scripts/listen_and_play.py --host <IP address of your server>
218
+ ```
219
+
220
+ ### WebSocket Approach
221
+
222
+ 1. Run the pipeline with WebSocket mode:
223
+ ```bash
224
+ speech-to-speech --mode websocket --ws_host 0.0.0.0 --ws_port 8765
225
+ ```
226
+
227
+ 2. Connect to the WebSocket server from your client application at `ws://<server-ip>:8765`. The server handles bidirectional audio streaming:
228
+ - Send raw audio bytes to the server (16kHz, int16, mono)
229
+ - Receive generated audio bytes from the server
230
+
231
+ ### Local Approach (Mac)
232
+
233
+ 1. For optimal settings on Mac:
234
+ ```bash
235
+ speech-to-speech --local_mac_optimal_settings
236
+ ```
237
+
238
+ You can also specify a particular LLM model:
239
+ ```bash
240
+ speech-to-speech \
241
+ --local_mac_optimal_settings \
242
+ --lm_model_name mlx-community/Qwen3-4B-Instruct-2507-bf16
243
+ ```
244
+
245
+ This setting:
246
+ - Adds `--device mps` to use MPS for all models.
247
+ - Sets [Parakeet TDT](https://huggingface.co/nvidia/parakeet-tdt-1.1b) for STT (fast streaming ASR on Apple Silicon)
248
+ - Sets MLX LM for the language model (uses `--lm_model_name` to specify the model)
249
+ - Sets Qwen3-TTS for TTS
250
+ - `--tts pocket` and `--tts kokoro` are also valid TTS options on macOS.
251
+ - Qwen3 on Apple Silicon uses `mlx-audio` and defaults to the `6bit` MLX variant unless you explicitly select a different quantization or model suffix.
252
+ - To compare the MLX variants locally, run:
253
+ ```bash
254
+ python scripts/benchmark_tts.py \
255
+ --handlers qwen3 \
256
+ --iterations 3 \
257
+ --qwen3_mlx_quantizations bf16 4bit 6bit 8bit
258
+ ```
259
+
260
+ ### Docker Server
261
+
262
+ #### Install the NVIDIA Container Toolkit
263
+
264
+ https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html
265
+
266
+ #### Start the docker container
267
+ ```docker compose up```
268
+
269
+
270
+
271
+ ### Recommended usage with Cuda
272
+
273
+ Leverage Torch Compile for Whisper with Pocket TTS for a simple low-latency setup:
274
+
275
+ ```bash
276
+ speech-to-speech \
277
+ --lm_model_name microsoft/Phi-3-mini-4k-instruct \
278
+ --stt_compile_mode reduce-overhead \
279
+ --tts pocket \
280
+ --recv_host 0.0.0.0 \
281
+ --send_host 0.0.0.0
282
+ ```
283
+
284
+ ### Multi-language Support
285
+
286
+ The pipeline currently supports English, French, Spanish, Chinese, Japanese, and Korean.
287
+ Two use cases are considered:
288
+
289
+ - **Single-language conversation**: Enforce the language setting using the `--language` flag, specifying the target language code (default is 'en').
290
+ - **Language switching**: Set `--language` to 'auto'. The STT detects the language of each spoken prompt and forwards it to the LLM. Optionally, opt in with `--lm_enable_lang_prompt` (or `--open_api_enable_lang_prompt` for the OpenAI-compatible backend) to also append a "`Please reply to my message in ...`" instruction so the LLM replies in the detected language. Both flags default to `False` — large LLMs usually pick up the language from context on their own, but the explicit instruction can help smaller models stay in the right language.
291
+
292
+ Please note that you must use STT and LLM checkpoints compatible with the target language(s). For multilingual TTS, use ChatTTS or another backend that supports the target language.
293
+
294
+ #### With the server version:
295
+
296
+ For automatic language detection:
297
+
298
+ ```bash
299
+ speech-to-speech \
300
+ --stt whisper-mlx \
301
+ --stt_model_name large-v3 \
302
+ --language auto \
303
+ --llm mlx-lm \
304
+ --lm_model_name mlx-community/Qwen3-4B-Instruct-2507-bf16
305
+ ```
306
+
307
+ Or for one language in particular, chinese in this example
308
+
309
+ ```bash
310
+ speech-to-speech \
311
+ --stt whisper-mlx \
312
+ --stt_model_name large-v3 \
313
+ --language zh \
314
+ --llm mlx-lm \
315
+ --lm_model_name mlx-community/Qwen3-4B-Instruct-2507-bf16
316
+ ```
317
+
318
+ #### Local Mac Setup
319
+
320
+ For automatic language detection (note: `--stt whisper-mlx` overrides the default parakeet-tdt from optimal settings, since Whisper `large-v3` has broader language coverage):
321
+
322
+ ```bash
323
+ speech-to-speech \
324
+ --local_mac_optimal_settings \
325
+ --stt whisper-mlx \
326
+ --stt_model_name large-v3 \
327
+ --language auto \
328
+ --lm_model_name mlx-community/Qwen3-4B-Instruct-2507-bf16
329
+ ```
330
+
331
+ Or for one language in particular, chinese in this example
332
+
333
+ ```bash
334
+ speech-to-speech \
335
+ --local_mac_optimal_settings \
336
+ --stt whisper-mlx \
337
+ --stt_model_name large-v3 \
338
+ --language zh \
339
+ --lm_model_name mlx-community/Qwen3-4B-Instruct-2507-bf16
340
+ ```
341
+
342
+ ### Using Pocket TTS
343
+
344
+ Pocket TTS from Kyutai Labs provides streaming TTS with voice cloning capabilities. To use it:
345
+
346
+ ```bash
347
+ speech-to-speech \
348
+ --tts pocket \
349
+ --pocket_tts_voice jean \
350
+ --pocket_tts_device cpu
351
+ ```
352
+
353
+ Available voice presets: `alba`, `marius`, `javert`, `jean`, `fantine`, `cosette`, `eponine`, `azelma`. You can also use custom voice files or HuggingFace paths.
354
+
355
+ ## Command-line Usage
356
+
357
+ > **_NOTE:_** References for all the CLI arguments can be found directly in the [arguments classes](./src/speech_to_speech/arguments_classes) or by running `speech-to-speech -h`.
358
+
359
+ ### Module level Parameters
360
+ See [ModuleArguments](./src/speech_to_speech/arguments_classes/module_arguments.py) class. Allows to set:
361
+ - a common `--device` (if one wants each part to run on the same device)
362
+ - `--mode` `local` or `server`
363
+ - chosen STT implementation
364
+ - chosen LM implementation
365
+ - chose TTS implementation
366
+ - logging level
367
+
368
+ ### VAD parameters
369
+ See [VADHandlerArguments](./src/speech_to_speech/arguments_classes/vad_arguments.py) class. Notably:
370
+ - `--thresh`: Threshold value to trigger voice activity detection.
371
+ - `--min_speech_ms`: Minimum duration of detected voice activity to be considered speech.
372
+ - `--min_silence_ms`: Minimum length of silence intervals for segmenting speech, balancing sentence cutting and latency reduction.
373
+
374
+
375
+ ### STT, LM and TTS parameters
376
+
377
+ `model_name`, `torch_dtype`, and `device` are exposed for each implementation of the Speech to Text, Language Model, and Text to Speech. Specify the targeted pipeline part with the corresponding prefix (e.g. `stt`, `lm` or `tts`, check the implementations' [arguments classes](./src/speech_to_speech/arguments_classes) for more details).
378
+
379
+ For example:
380
+ ```bash
381
+ --lm_model_name google/gemma-2b-it
382
+ ```
383
+
384
+ ### Generation parameters
385
+
386
+ Other generation parameters of the model's generate method can be set using the part's prefix + `_gen_`, e.g., `--stt_gen_max_new_tokens 128`. These parameters can be added to the pipeline part's arguments class if not already exposed.
387
+
388
+ ## Citations
389
+
390
+ ### Silero VAD
391
+ ```bibtex
392
+ @misc{Silero VAD,
393
+ author = {Silero Team},
394
+ title = {Silero VAD: pre-trained enterprise-grade Voice Activity Detector (VAD), Number Detector and Language Classifier},
395
+ year = {2021},
396
+ publisher = {GitHub},
397
+ journal = {GitHub repository},
398
+ howpublished = {\url{https://github.com/snakers4/silero-vad}},
399
+ commit = {insert_some_commit_here},
400
+ email = {hello@silero.ai}
401
+ }
402
+ ```
403
+
404
+ ### Distil-Whisper
405
+ ```bibtex
406
+ @misc{gandhi2023distilwhisper,
407
+ title={Distil-Whisper: Robust Knowledge Distillation via Large-Scale Pseudo Labelling},
408
+ author={Sanchit Gandhi and Patrick von Platen and Alexander M. Rush},
409
+ year={2023},
410
+ eprint={2311.00430},
411
+ archivePrefix={arXiv},
412
+ primaryClass={cs.CL}
413
+ }
414
+ ```
415
+
416
+ ### Parler-TTS
417
+ ```bibtex
418
+ @misc{lacombe-etal-2024-parler-tts,
419
+ author = {Yoach Lacombe and Vaibhav Srivastav and Sanchit Gandhi},
420
+ title = {Parler-TTS},
421
+ year = {2024},
422
+ publisher = {GitHub},
423
+ journal = {GitHub repository},
424
+ howpublished = {\url{https://github.com/huggingface/parler-tts}}
425
+ }
426
+ ```