rkvoice-stream 0.1.1__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 (111) hide show
  1. rkvoice_stream-0.1.1/LICENSE +175 -0
  2. rkvoice_stream-0.1.1/PKG-INFO +381 -0
  3. rkvoice_stream-0.1.1/README.md +357 -0
  4. rkvoice_stream-0.1.1/pyproject.toml +27 -0
  5. rkvoice_stream-0.1.1/rkvoice_stream/__init__.py +243 -0
  6. rkvoice_stream-0.1.1/rkvoice_stream/app/__init__.py +0 -0
  7. rkvoice_stream-0.1.1/rkvoice_stream/app/capability.py +288 -0
  8. rkvoice_stream-0.1.1/rkvoice_stream/app/dialogue.py +281 -0
  9. rkvoice_stream-0.1.1/rkvoice_stream/app/resource_planner.py +87 -0
  10. rkvoice_stream-0.1.1/rkvoice_stream/app/server.py +750 -0
  11. rkvoice_stream-0.1.1/rkvoice_stream/backends/__init__.py +1 -0
  12. rkvoice_stream-0.1.1/rkvoice_stream/backends/asr/__init__.py +0 -0
  13. rkvoice_stream-0.1.1/rkvoice_stream/backends/asr/paraformer_rknn.py +948 -0
  14. rkvoice_stream-0.1.1/rkvoice_stream/backends/asr/paraformer_sherpa.py +290 -0
  15. rkvoice_stream-0.1.1/rkvoice_stream/backends/asr/qwen3/__init__.py +29 -0
  16. rkvoice_stream-0.1.1/rkvoice_stream/backends/asr/qwen3/chunk_confirm.py +762 -0
  17. rkvoice_stream-0.1.1/rkvoice_stream/backends/asr/qwen3/config.py +77 -0
  18. rkvoice_stream-0.1.1/rkvoice_stream/backends/asr/qwen3/decoder.py +688 -0
  19. rkvoice_stream-0.1.1/rkvoice_stream/backends/asr/qwen3/encoder.py +299 -0
  20. rkvoice_stream-0.1.1/rkvoice_stream/backends/asr/qwen3/engine.py +627 -0
  21. rkvoice_stream-0.1.1/rkvoice_stream/backends/asr/qwen3/matmul_decoder.py +306 -0
  22. rkvoice_stream-0.1.1/rkvoice_stream/backends/asr/qwen3/mel.py +67 -0
  23. rkvoice_stream-0.1.1/rkvoice_stream/backends/asr/qwen3/stream.py +767 -0
  24. rkvoice_stream-0.1.1/rkvoice_stream/backends/asr/qwen3/streaming.py +970 -0
  25. rkvoice_stream-0.1.1/rkvoice_stream/backends/asr/qwen3/utils.py +235 -0
  26. rkvoice_stream-0.1.1/rkvoice_stream/backends/asr/qwen3_rk.py +608 -0
  27. rkvoice_stream-0.1.1/rkvoice_stream/backends/asr/sensevoice_rknn.py +286 -0
  28. rkvoice_stream-0.1.1/rkvoice_stream/backends/asr/sensevoice_sherpa.py +373 -0
  29. rkvoice_stream-0.1.1/rkvoice_stream/backends/audio_llm/__init__.py +0 -0
  30. rkvoice_stream-0.1.1/rkvoice_stream/backends/audio_llm/gemma4_rk1828.py +221 -0
  31. rkvoice_stream-0.1.1/rkvoice_stream/backends/custom_ops/__init__.py +0 -0
  32. rkvoice_stream-0.1.1/rkvoice_stream/backends/custom_ops/rknn_custom_ops.py +200 -0
  33. rkvoice_stream-0.1.1/rkvoice_stream/backends/tts/__init__.py +0 -0
  34. rkvoice_stream-0.1.1/rkvoice_stream/backends/tts/kokoro_rknn.py +1202 -0
  35. rkvoice_stream-0.1.1/rkvoice_stream/backends/tts/matcha.py +909 -0
  36. rkvoice_stream-0.1.1/rkvoice_stream/backends/tts/moss_ort.py +1606 -0
  37. rkvoice_stream-0.1.1/rkvoice_stream/backends/tts/moss_rknn.py +450 -0
  38. rkvoice_stream-0.1.1/rkvoice_stream/backends/tts/piper.py +916 -0
  39. rkvoice_stream-0.1.1/rkvoice_stream/backends/tts/qwen3_rknn.py +116 -0
  40. rkvoice_stream-0.1.1/rkvoice_stream/backends/tts/qwen3_tts.py +1252 -0
  41. rkvoice_stream-0.1.1/rkvoice_stream/backends/tts/qwen3_tts_rk1828.py +288 -0
  42. rkvoice_stream-0.1.1/rkvoice_stream/engine/__init__.py +1 -0
  43. rkvoice_stream-0.1.1/rkvoice_stream/engine/asr.py +222 -0
  44. rkvoice_stream-0.1.1/rkvoice_stream/engine/audio_llm.py +96 -0
  45. rkvoice_stream-0.1.1/rkvoice_stream/engine/tts.py +117 -0
  46. rkvoice_stream-0.1.1/rkvoice_stream/platform/__init__.py +22 -0
  47. rkvoice_stream-0.1.1/rkvoice_stream/platform/base.py +40 -0
  48. rkvoice_stream-0.1.1/rkvoice_stream/platform/rk1828.py +26 -0
  49. rkvoice_stream-0.1.1/rkvoice_stream/platform/rk3576.py +15 -0
  50. rkvoice_stream-0.1.1/rkvoice_stream/platform/rk3588.py +15 -0
  51. rkvoice_stream-0.1.1/rkvoice_stream/runtime/__init__.py +0 -0
  52. rkvoice_stream-0.1.1/rkvoice_stream/runtime/rkllm_wrapper.py +383 -0
  53. rkvoice_stream-0.1.1/rkvoice_stream/runtime/rknn3_worker.py +688 -0
  54. rkvoice_stream-0.1.1/rkvoice_stream/vad/__init__.py +0 -0
  55. rkvoice_stream-0.1.1/rkvoice_stream/vad/silero.py +168 -0
  56. rkvoice_stream-0.1.1/rkvoice_stream.egg-info/PKG-INFO +381 -0
  57. rkvoice_stream-0.1.1/rkvoice_stream.egg-info/SOURCES.txt +109 -0
  58. rkvoice_stream-0.1.1/rkvoice_stream.egg-info/dependency_links.txt +1 -0
  59. rkvoice_stream-0.1.1/rkvoice_stream.egg-info/requires.txt +16 -0
  60. rkvoice_stream-0.1.1/rkvoice_stream.egg-info/top_level.txt +1 -0
  61. rkvoice_stream-0.1.1/setup.cfg +4 -0
  62. rkvoice_stream-0.1.1/tests/test_asr.py +105 -0
  63. rkvoice_stream-0.1.1/tests/test_capability_device_id.py +167 -0
  64. rkvoice_stream-0.1.1/tests/test_convert_moss_rknn_workspace.py +204 -0
  65. rkvoice_stream-0.1.1/tests/test_dialogue_streaming.py +100 -0
  66. rkvoice_stream-0.1.1/tests/test_extract_moss_rknn_island_workspace.py +109 -0
  67. rkvoice_stream-0.1.1/tests/test_latency.py +127 -0
  68. rkvoice_stream-0.1.1/tests/test_moss_backend_stream_profiler.py +63 -0
  69. rkvoice_stream-0.1.1/tests/test_moss_canonical_deployment_evidence.py +80 -0
  70. rkvoice_stream-0.1.1/tests/test_moss_deployment_path_evidence.py +24 -0
  71. rkvoice_stream-0.1.1/tests/test_moss_disk_audit.py +198 -0
  72. rkvoice_stream-0.1.1/tests/test_moss_hybrid_sampler_compare.py +52 -0
  73. rkvoice_stream-0.1.1/tests/test_moss_ort_artifacts.py +420 -0
  74. rkvoice_stream-0.1.1/tests/test_moss_ort_backend.py +458 -0
  75. rkvoice_stream-0.1.1/tests/test_moss_ort_config_verifier.py +99 -0
  76. rkvoice_stream-0.1.1/tests/test_moss_ort_deployment_dry_run_evidence.py +26 -0
  77. rkvoice_stream-0.1.1/tests/test_moss_ort_roundtrip_verifier.py +157 -0
  78. rkvoice_stream-0.1.1/tests/test_moss_production_entrypoint_evidence.py +61 -0
  79. rkvoice_stream-0.1.1/tests/test_moss_production_entrypoint_verifier.py +65 -0
  80. rkvoice_stream-0.1.1/tests/test_moss_production_evidence.py +88 -0
  81. rkvoice_stream-0.1.1/tests/test_moss_production_profile_verifier.py +140 -0
  82. rkvoice_stream-0.1.1/tests/test_moss_production_server_disk_gate_evidence.py +22 -0
  83. rkvoice_stream-0.1.1/tests/test_moss_production_server_runner.py +327 -0
  84. rkvoice_stream-0.1.1/tests/test_moss_release_audit.py +212 -0
  85. rkvoice_stream-0.1.1/tests/test_moss_release_audit_artifact_gate_evidence.py +26 -0
  86. rkvoice_stream-0.1.1/tests/test_moss_rknn_artifacts.py +443 -0
  87. rkvoice_stream-0.1.1/tests/test_moss_rknn_config.py +22 -0
  88. rkvoice_stream-0.1.1/tests/test_moss_sampler_profiler.py +53 -0
  89. rkvoice_stream-0.1.1/tests/test_moss_service_profile_verifier.py +55 -0
  90. rkvoice_stream-0.1.1/tests/test_moss_service_streaming_verifier.py +327 -0
  91. rkvoice_stream-0.1.1/tests/test_moss_signal_smoke_evidence.py +20 -0
  92. rkvoice_stream-0.1.1/tests/test_moss_streaming_stats_evidence.py +27 -0
  93. rkvoice_stream-0.1.1/tests/test_npu_coexist.py +116 -0
  94. rkvoice_stream-0.1.1/tests/test_paraformer_rknn_decode.py +25 -0
  95. rkvoice_stream-0.1.1/tests/test_prepare_moss_ort_deployment.py +124 -0
  96. rkvoice_stream-0.1.1/tests/test_prepare_rknn_workspace.py +207 -0
  97. rkvoice_stream-0.1.1/tests/test_qwen3_decoder_stop_policy.py +24 -0
  98. rkvoice_stream-0.1.1/tests/test_qwen3_engine_artifact_lookup.py +90 -0
  99. rkvoice_stream-0.1.1/tests/test_qwen3_rk_stream_mode.py +130 -0
  100. rkvoice_stream-0.1.1/tests/test_qwen3_true_streaming_config.py +166 -0
  101. rkvoice_stream-0.1.1/tests/test_rk1828_audio_dialogue.py +400 -0
  102. rkvoice_stream-0.1.1/tests/test_rk1828_gemma4.py +367 -0
  103. rkvoice_stream-0.1.1/tests/test_rk1828_tts.py +383 -0
  104. rkvoice_stream-0.1.1/tests/test_rk3576_performance_mode.py +75 -0
  105. rkvoice_stream-0.1.1/tests/test_rknn_workspace_gate_evidence.py +126 -0
  106. rkvoice_stream-0.1.1/tests/test_roundtrip.py +108 -0
  107. rkvoice_stream-0.1.1/tests/test_server_health_runtime_info.py +234 -0
  108. rkvoice_stream-0.1.1/tests/test_tts.py +86 -0
  109. rkvoice_stream-0.1.1/tests/test_v2v_streaming.py +278 -0
  110. rkvoice_stream-0.1.1/tests/test_verify_rknn_artifact_workspace.py +69 -0
  111. rkvoice_stream-0.1.1/tests/test_verify_rknn_workspace_deployment.py +105 -0
@@ -0,0 +1,175 @@
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
+
39
+ "Derivative Works" shall mean any work, whether in Source or Object
40
+ form, that is based on (or derived from) the Work and for which the
41
+ editorial revisions, annotations, elaborations, or other modifications
42
+ represent, as a whole, an original work of authorship. For the purposes
43
+ of this License, Derivative Works shall not include works that remain
44
+ separable from, or merely link (or bind by name) to the interfaces of,
45
+ the Work and Derivative Works thereof.
46
+
47
+ "Contribution" shall mean any work of authorship, including
48
+ the original version of the Work and any modifications or additions
49
+ to that Work or Derivative Works thereof, that is intentionally
50
+ submitted to the Licensor for inclusion in the Work by the copyright owner
51
+ or by an individual or Legal Entity authorized to submit on behalf of
52
+ the copyright owner. For the purposes of this definition, "submitted"
53
+ means any form of electronic, verbal, or written communication sent
54
+ to the Licensor or its representatives, including but not limited to
55
+ communication on electronic mailing lists, source code control systems,
56
+ and issue tracking systems that are managed by, or on behalf of, the
57
+ Licensor for the purpose of discussing and improving the Work, but
58
+ excluding communication that is conspicuously marked or otherwise
59
+ designated in writing by the copyright owner as "Not a Contribution."
60
+
61
+ "Contributor" shall mean Licensor and any individual or Legal Entity
62
+ on behalf of whom a Contribution has been received by the Licensor and
63
+ subsequently incorporated within the Work.
64
+
65
+ 2. Grant of Copyright License. Subject to the terms and conditions of
66
+ this License, each Contributor hereby grants to You a perpetual,
67
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
68
+ copyright license to reproduce, prepare Derivative Works of,
69
+ publicly display, publicly perform, sublicense, and distribute the
70
+ Work and such Derivative Works in Source or Object form.
71
+
72
+ 3. Grant of Patent License. Subject to the terms and conditions of
73
+ this License, each Contributor hereby grants to You a perpetual,
74
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
75
+ (except as stated in this section) patent license to make, have made,
76
+ use, offer to sell, sell, import, and otherwise transfer the Work,
77
+ where such license applies only to those patent claims licensable
78
+ by such Contributor that are necessarily infringed by their
79
+ Contribution(s) alone or by combination of their Contribution(s)
80
+ with the Work to which such Contribution(s) was submitted. If You
81
+ institute patent litigation against any entity (including a
82
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
83
+ or a Contribution incorporated within the Work constitutes direct
84
+ or contributory patent infringement, then any patent licenses
85
+ granted to You under this License for that Work shall terminate
86
+ as of the date such litigation is filed.
87
+
88
+ 4. Redistribution. You may reproduce and distribute copies of the
89
+ Work or Derivative Works thereof in any medium, with or without
90
+ modifications, and in Source or Object form, provided that You
91
+ meet the following conditions:
92
+
93
+ (a) You must give any other recipients of the Work or
94
+ Derivative Works a copy of this License; and
95
+
96
+ (b) You must cause any modified files to carry prominent notices
97
+ stating that You changed the files; and
98
+
99
+ (c) You must retain, in the Source form of any Derivative Works
100
+ that You distribute, all copyright, patent, trademark, and
101
+ attribution notices from the Source form of the Work,
102
+ excluding those notices that do not pertain to any part of
103
+ the Derivative Works; and
104
+
105
+ (d) If the Work includes a "NOTICE" text file as part of its
106
+ distribution, then any Derivative Works that You distribute must
107
+ include a readable copy of the attribution notices contained
108
+ within such NOTICE file, excluding any notices that do not
109
+ pertain to any part of the Derivative Works, in at least one
110
+ of the following places: within a NOTICE text file distributed
111
+ as part of the Derivative Works; within the Source form or
112
+ documentation, if provided along with the Derivative Works; or,
113
+ within a display generated by the Derivative Works, if and
114
+ wherever such third-party notices normally appear. The contents
115
+ of the NOTICE file are for informational purposes only and
116
+ do not modify the License. You may add Your own attribution
117
+ notices within Derivative Works that You distribute, alongside
118
+ or as an addendum to the NOTICE text from the Work, provided
119
+ that such additional attribution notices cannot be construed
120
+ as modifying the License.
121
+
122
+ You may add Your own copyright statement to Your modifications and
123
+ may provide additional or different license terms and conditions
124
+ for use, reproduction, or distribution of Your modifications, or
125
+ for any such Derivative Works as a whole, provided Your use,
126
+ reproduction, and distribution of the Work otherwise complies with
127
+ the conditions stated in this License.
128
+
129
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
130
+ any Contribution intentionally submitted for inclusion in the Work
131
+ by You to the Licensor shall be under the terms and conditions of
132
+ this License, without any additional terms or conditions.
133
+ Notwithstanding the above, nothing herein shall supersede or modify
134
+ the terms of any separate license agreement you may have executed
135
+ with Licensor regarding such Contributions.
136
+
137
+ 6. Trademarks. This License does not grant permission to use the trade
138
+ names, trademarks, service marks, or product names of the Licensor,
139
+ except as required for reasonable and customary use in describing the
140
+ origin of the Work and reproducing the content of the NOTICE file.
141
+
142
+ 7. Disclaimer of Warranty. Unless required by applicable law or
143
+ agreed to in writing, Licensor provides the Work (and each
144
+ Contributor provides its Contributions) on an "AS IS" BASIS,
145
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
146
+ implied, including, without limitation, any warranties or conditions
147
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
148
+ PARTICULAR PURPOSE. You are solely responsible for determining the
149
+ appropriateness of using or redistributing the Work and assume any
150
+ risks associated with Your exercise of permissions under this License.
151
+
152
+ 8. Limitation of Liability. In no event and under no legal theory,
153
+ whether in tort (including negligence), contract, or otherwise,
154
+ unless required by applicable law (such as deliberate and grossly
155
+ negligent acts) or agreed to in writing, shall any Contributor be
156
+ liable to You for damages, including any direct, indirect, special,
157
+ incidental, or consequential damages of any character arising as a
158
+ result of this License or out of the use or inability to use the
159
+ Work (including but not limited to damages for loss of goodwill,
160
+ work stoppage, computer failure or malfunction, or any and all
161
+ other commercial damages or losses), even if such Contributor
162
+ has been advised of the possibility of such damages.
163
+
164
+ 9. Accepting Warranty or Additional Liability. While redistributing
165
+ the Work or Derivative Works thereof, You may choose to offer,
166
+ and charge a fee for, acceptance of support, warranty, indemnity,
167
+ or other liability obligations and/or rights consistent with this
168
+ License. However, in accepting such obligations, You may act only
169
+ on Your own behalf and on Your sole responsibility, not on behalf
170
+ of any other Contributor, and only if You agree to indemnify,
171
+ defend, and hold each Contributor harmless for any liability
172
+ incurred by, or claims asserted against, such Contributor by reason
173
+ of your accepting any such warranty or additional liability.
174
+
175
+ END OF TERMS AND CONDITIONS
@@ -0,0 +1,381 @@
1
+ Metadata-Version: 2.4
2
+ Name: rkvoice-stream
3
+ Version: 0.1.1
4
+ Summary: Streaming speech AI on Rockchip NPU platforms (ASR + TTS)
5
+ License: Apache-2.0
6
+ Requires-Python: >=3.10
7
+ Description-Content-Type: text/markdown
8
+ License-File: LICENSE
9
+ Requires-Dist: numpy<2
10
+ Requires-Dist: soundfile
11
+ Requires-Dist: fastapi
12
+ Requires-Dist: uvicorn[standard]
13
+ Requires-Dist: python-multipart
14
+ Requires-Dist: pydantic
15
+ Requires-Dist: pyyaml
16
+ Provides-Extra: dev
17
+ Requires-Dist: pytest; extra == "dev"
18
+ Requires-Dist: requests; extra == "dev"
19
+ Requires-Dist: websocket-client; extra == "dev"
20
+ Provides-Extra: moss
21
+ Requires-Dist: onnxruntime; extra == "moss"
22
+ Requires-Dist: sentencepiece; extra == "moss"
23
+ Dynamic: license-file
24
+
25
+ <p align="center">
26
+ <img src="media/logo.png" alt="rkvoice-stream" width="200">
27
+ </p>
28
+
29
+ <h1 align="center">rkvoice-stream</h1>
30
+
31
+ <p align="center">
32
+ <a href="LICENSE"><img src="https://img.shields.io/badge/License-Apache_2.0-blue.svg" alt="License"></a>
33
+ <img src="https://img.shields.io/badge/Python-3.10+-green.svg" alt="Python">
34
+ <img src="https://img.shields.io/badge/Platform-RK3576%20%7C%20RK3588%20%7C%20RK1828%20(NPU%20coprocessor)-orange.svg" alt="Platform">
35
+ </p>
36
+
37
+ <p align="center">
38
+ Deploy streaming ASR + TTS on RK3576/RK3588 — <strong>120ms TTS latency, 52-language ASR, one Docker command.</strong>
39
+ </p>
40
+
41
+ <!-- TODO: Add demo GIF here — record a terminal session showing:
42
+ 1. docker-compose up (service starts)
43
+ 2. curl POST /tts with Chinese text → WAV file plays
44
+ 3. WebSocket /asr/stream with microphone → real-time transcription
45
+ Target length: ~15 seconds -->
46
+
47
+ ## What is this?
48
+
49
+ rkvoice-stream is a ready-to-deploy speech AI service for Rockchip NPU devices. It runs ASR and TTS entirely on-device via RKNN/RKLLM acceleration — no cloud, no GPU, no internet required. Ship it as a Python library or a Docker container.
50
+
51
+ It also supports the **RK1828 PCIe NPU coprocessor** (an accelerator card attached to an RK3576/RK3588 host) for on-device TTS (`qwen3_tts_rk1828`) and a multimodal **AudioLLM** (`gemma4_rk1828`, Gemma-4) that takes audio and streams text — collapsing ASR + LLM into a single model.
52
+
53
+ ## Table of Contents
54
+
55
+ - [Performance](#performance)
56
+ - [AudioLLM — Gemma-4 (RK1828)](#audiollm--gemma-4-rk1828)
57
+ - [Features](#features)
58
+ - [Supported Platforms](#supported-platforms)
59
+ - [Quick Start](#quick-start)
60
+ - [API Reference](#api-reference)
61
+ - [Architecture](#architecture)
62
+ - [Model Preparation](#model-preparation)
63
+ - [Configuration](#configuration)
64
+ - [Testing](#testing)
65
+ - [Acknowledgements](#acknowledgements)
66
+ - [License](#license)
67
+
68
+ ## Performance
69
+
70
+ ### ASR — five backends
71
+
72
+ | Backend | Languages | Type | RK3576 RTF | RK3588 RTF | RK3576 TTFW | RK3588 TTFW | RK3576 Finalize | RK3588 Finalize |
73
+ |---------|:---------:|------|:----------:|:----------:|:-----------:|:-----------:|:---------------:|:---------------:|
74
+ | **Qwen3-ASR** (NPU) | 52 | RKNN encoder + RKLLM decoder | 0.36 | 0.23 | ~1.1s | ~1.2s | ~6.5s | ~3.7s |
75
+ | **Paraformer** (Hybrid) | 4 | RKNN encoder prefix + CPU suffix/decoder | 0.29 | 0.33 | — | — | — | — |
76
+ | **Paraformer** (CPU) | 4 | sherpa-onnx streaming | 0.50 | 0.24 | — | — | — | — |
77
+ | **SenseVoice** (NPU) | 50+ | RKNN encoder + CPU CTC | — | — | — | — | — | — |
78
+ | **SenseVoice** (CPU) | 50+ | sherpa-onnx | 0.36 | 0.11 | — | — | — | — |
79
+
80
+ > TTFW = time to first word (streaming partial via chunk-confirm). Finalize = latency from end-of-audio to final transcript. Qwen3-ASR requires `ASR_ENCODER_SIZES=2,4,15` to load all three encoder windows; omitting the 2s/4s models disables real-time partials. RK3576 uses w4a16_g128 RKLLM decoder; RK3588 uses w8a8.
81
+
82
+ ### TTS — six backends
83
+
84
+ | Backend | Languages | Type | RK3576 RTF | RK3588 RTF | RK3576 TTFA | RK3588 TTFA |
85
+ |---------|-----------|------|:----------:|:----------:|:-----------:|:-----------:|
86
+ | **Matcha + Vocos** | zh, en | RKNN vocoder (NPU) | 0.13 | 0.05 | ~320ms | ~145ms |
87
+ | **Piper VITS** | en, zh, de, fr, ja, … | Hybrid CPU + NPU | 0.17 | 0.13 | ~234ms | ~142ms |
88
+ | **Kokoro** | en, zh | RKNN (NPU) | — | 0.77 | — | ~800ms / ~1.8s / ~3.5s |
89
+ | **Qwen3-TTS** | zh, en | RKNN (NPU) | — | — | — | — |
90
+ | **Qwen3-TTS (RK1828)** | zh, en | RKNN3 on RK1828 PCIe NPU coprocessor | — | — | — | — |
91
+
92
+ > TTFA = time to first audio chunk via `/tts/stream`, sentence-level streaming (warm, after first inference). Kokoro uses three-tier bucket routing on RK3588: bucket-8 (~800ms, &le;8 tokens), bucket-16 (~1.8s, 9–16 tokens), bucket-32 (~3.5s, 17–32 tokens).
93
+
94
+ > **Qwen3-TTS (RK1828)** — `qwen3_tts_rk1828` runs Qwen3-TTS (~1.7 GB) on the RK1828 PCIe
95
+ > NPU coprocessor via the RKNN3 toolchain (driven by a subprocess worker over PCIe). See
96
+ > [`docs/rk1828-qwen3-tts.md`](docs/rk1828-qwen3-tts.md).
97
+
98
+ ### Voice-to-Voice (EOS → First Audio)
99
+
100
+ Streaming V2V latency: time from user stops speaking to first TTS audio chunk.
101
+ Audio streamed at real-time pace (simulating live microphone). Qwen3-ASR (NPU) + Matcha TTS.
102
+
103
+ | Sentence | RK3576 | RK3588 |
104
+ |----------|:------:|:------:|
105
+ | 你好世界 (1.5s) | 949 ms | **685 ms** |
106
+ | 今天天气真不错 (2.0s) | 1604 ms | **1429 ms** |
107
+ | 语音识别测试 (3.1s) | 1700 ms | **1408 ms** |
108
+ | Hello world (1.7s) | 1289 ms | **644 ms** |
109
+ | **Average** | **1385 ms** | **1042 ms** |
110
+
111
+ ## AudioLLM — Gemma-4 (RK1828)
112
+
113
+ A new engine type beyond ASR and TTS: an **AudioLLM** consumes audio (plus an optional
114
+ text prompt) and **streams text** back, collapsing the ASR + LLM "understanding" steps of a
115
+ voice-to-voice pipeline into a single multimodal model.
116
+
117
+ | Backend | Input → Output | Type | Platform | Status |
118
+ |---------|----------------|------|----------|--------|
119
+ | **Gemma-4** (`gemma4_rk1828`) | audio (+ optional prompt) → streaming text | RKNN3 (subprocess worker over PCIe) | RK1828 PCIe NPU coprocessor (~4.2 GB) | experimental |
120
+
121
+ Used by the `/audio_dialogue` WebSocket endpoint for V2V: audio in → AudioLLM streaming text
122
+ → TTS → audio out.
123
+
124
+ > **Single-EP constraint** — the RK1828 has a single ~5 GB NPU. Gemma-4 (~4.2 GB) and
125
+ > Qwen3-TTS (~1.7 GB) do not fit at the same time, so V2V runs Gemma-4 on the RK1828 with
126
+ > TTS on the host SoC's NPU, or time-shares the coprocessor between them.
127
+
128
+ > **Experimental — firmware flakiness.** Loading Gemma-4 on the RK1828 occasionally hits a
129
+ > firmware `ACK_FAIL` during model setup (an RKNN3 V1.0.4 firmware-layer issue, mitigated by
130
+ > worker-level retry). See [`docs/rk1828-upstream-modelsetup-ackfail.md`](docs/rk1828-upstream-modelsetup-ackfail.md)
131
+ > and [`docs/rk1828-gemma4.md`](docs/rk1828-gemma4.md).
132
+
133
+ ## Features
134
+
135
+ - **ASR: Qwen3-ASR** — streaming + offline, 52 languages, RKNN encoder + RKLLM decoder on NPU
136
+ - **ASR: Paraformer RKNN** — experimental hybrid split: FP16 RKNN encoder prefix through block30, CPU ONNX encoder suffix and decoder; boundary parity verified on RK3588 and RK3576
137
+ - **ASR: SenseVoice RKNN** — offline, 50+ languages, RKNN encoder + CPU CTC decode
138
+ - **ASR: SenseVoice** — offline + VAD streaming, 50+ languages, CPU (sherpa-onnx)
139
+ - **ASR: Paraformer** — native streaming, zh/en/ja/ko, CPU (sherpa-onnx)
140
+ - **TTS: Matcha + Vocos** — high-quality Chinese/English synthesis, NPU-accelerated vocoder
141
+ - **TTS: Piper VITS** — lightweight multi-language TTS (en, zh, de, fr, ja, …), hybrid CPU+NPU
142
+ - **TTS: Kokoro RKNN** — multi-stage RKNN synthesis (en, zh), NPU-accelerated
143
+ - **TTS: Qwen3-TTS** — RKNN streaming TTS (zh, en) on NPU
144
+ - **TTS: Qwen3-TTS (RK1828)** — `qwen3_tts_rk1828`, Qwen3-TTS on the RK1828 PCIe NPU coprocessor (RKNN3)
145
+ - **AudioLLM: Gemma-4 multimodal (audio→text) on RK1828 PCIe NPU** — `gemma4_rk1828`, streams text from audio (+ optional prompt), powering single-model V2V (experimental)
146
+ - **Streaming everywhere** — WebSocket ASR (real-time partials), streaming TTS (sentence-by-sentence PCM)
147
+ - **Voice-to-voice pipeline** — ASR → LLM → TTS dialogue orchestrator with sub-second first-audio latency
148
+ - **NPU accelerated** — runs on Rockchip RKNN/RKLLM, not CPU
149
+ - **Config profiles** — pre-validated YAML configs for common setups (ASR-only, TTS-only, full stack)
150
+ - **jetson-voice compatible** — same HTTP/WebSocket API, drop-in replacement for RK platforms
151
+
152
+ ## Supported Platforms
153
+
154
+ | Platform | NPU | CPU | RKLLM Quant | V2V Latency | Status |
155
+ |----------|-----|-----|-------------|:-----------:|--------|
156
+ | RK3576 | 2 cores, 6 TOPS | 2x A72 + 4x A55 | W4A16 | ~1.1s | Tested |
157
+ | RK3588 | 3 cores, 6 TOPS | 4x A76 + 4x A55 | FP16 | **~0.7s** | Tested |
158
+ | RK1828 | PCIe NPU coprocessor (~5 GB, RKNN3), attached to RK3576/RK3588 host; device `0001:11:00.0` | host SoC | — | — | Experimental |
159
+
160
+ > **RK1828** is a PCIe NPU coprocessor (accelerator card), **not** a standalone SoC. It plugs
161
+ > into an RK3576/RK3588 host and uses a **different toolchain (RKNN3)** than the host's RKNN2;
162
+ > it is driven by a subprocess worker over PCIe (C++ server-mode demo). Backends:
163
+ > `qwen3_tts_rk1828` (TTS) and `gemma4_rk1828` (AudioLLM). See
164
+ > [`docs/rk1828-package-integration.md`](docs/rk1828-package-integration.md) for the full
165
+ > first-class-platform design.
166
+
167
+ ## Quick Start
168
+
169
+ ### Option 1: Docker (recommended)
170
+
171
+ ```bash
172
+ # Build
173
+ cd docker && docker build -t rkvoice-stream -f Dockerfile .. && cd ..
174
+
175
+ # Run with pre-validated config
176
+ docker-compose -f docker/docker-compose.yml up
177
+ ```
178
+
179
+ ### Option 2: Python library
180
+
181
+ ```bash
182
+ pip install /path/to/rkvoice-stream
183
+ ```
184
+
185
+ ```python
186
+ from rkvoice_stream import create_asr, create_tts
187
+
188
+ # ASR
189
+ asr = create_asr(backend="qwen3_asr_rk", model_dir="/opt/models/asr", platform="rk3576")
190
+ result = asr.transcribe("audio.wav", language="Chinese")
191
+ print(result.text)
192
+
193
+ # Streaming ASR
194
+ stream = asr.create_stream(language="Chinese")
195
+ stream.feed_audio(audio_chunk)
196
+ final = stream.finish()
197
+
198
+ # TTS
199
+ tts = create_tts(backend="matcha_rknn", model_dir="/opt/models/tts", platform="rk3576")
200
+ wav_bytes = tts.synthesize("Hello world")
201
+
202
+ # Streaming TTS
203
+ for chunk, meta in tts.synthesize_stream("Hello world"):
204
+ play(chunk)
205
+
206
+ # AudioLLM (Gemma-4 on RK1828): audio (+ optional prompt) -> streaming text
207
+ from rkvoice_stream.engine.audio_llm import create_audio_llm
208
+
209
+ audio_llm = create_audio_llm("gemma4_rk1828") # or AUDIO_LLM_BACKEND env
210
+ audio_llm.preload()
211
+ for token in audio_llm.generate_stream(audio, sample_rate=16000, prompt="Reply in English."):
212
+ print(token, end="", flush=True)
213
+ ```
214
+
215
+ ### Option 3: Config profile
216
+
217
+ ```python
218
+ from rkvoice_stream import load_config, create_from_config
219
+
220
+ config = load_config("configs/rk3576-full.yaml")
221
+ asr, tts = create_from_config(config)
222
+ ```
223
+
224
+ ## API Reference
225
+
226
+ All endpoints are compatible with [jetson-voice](https://github.com/dusty-nv/jetson-voice) clients.
227
+
228
+ | Method | Path | Description |
229
+ |--------|------|-------------|
230
+ | POST | `/tts` | Synthesize text to WAV |
231
+ | POST | `/tts/stream` | Streaming TTS (PCM chunks) |
232
+ | POST | `/asr` | Transcribe audio file |
233
+ | WS | `/asr/stream` | Streaming ASR (real-time partials) |
234
+ | WS | `/dialogue` | Voice-to-voice dialogue pipeline (ASR → LLM → TTS) |
235
+ | WS | `/audio_dialogue` | Voice-to-voice via AudioLLM (audio → AudioLLM streaming text → TTS → audio) |
236
+ | GET | `/health` | Service health + backend status |
237
+ | GET | `/capabilities` | NPU resource usage + conflict info |
238
+
239
+ ## Architecture
240
+
241
+ ```
242
+ ┌──────────────────────────────────────────────────┐
243
+ │ Application Layer │
244
+ │ FastAPI server, WebSocket streaming, dialogue, │
245
+ │ capability/conflict detection │
246
+ ├──────────────────────────────────────────────────┤
247
+ │ Engine Layer (public API) │
248
+ │ ASREngine ABC + TTSEngine ABC + AudioLLM ABC │
249
+ │ + factories │
250
+ ├──────────────────────────────────────────────────┤
251
+ │ Backend Layer │
252
+ │ Qwen3-ASR (RKNN + RKLLM) │ Matcha+Vocos │
253
+ │ Piper VITS (RKNN) │ Qwen3-TTS │
254
+ │ Gemma-4 (RK1828 AudioLLM) │ Qwen3-TTS (RK1828) │
255
+ ├──────────────────────────────────────────────────┤
256
+ │ Platform + Runtime │
257
+ │ RK3576/RK3588 configs, RKNN/RKLLM wrappers, │
258
+ │ RK1828 (RKNN3, subprocess worker over PCIe) │
259
+ └──────────────────────────────────────────────────┘
260
+ ```
261
+
262
+ Data flow (streaming ASR):
263
+ ```
264
+ Mic → int16 PCM → [WebSocket] → VAD → Mel → RKNN Encoder → RKLLM Decoder → Text
265
+ NPU NPU
266
+ ```
267
+
268
+ Data flow (streaming TTS):
269
+ ```
270
+ Text → Phonemes → Matcha (NPU) → Mel → Vocos (NPU) → ISTFT (CPU) → PCM → [WebSocket]
271
+ ```
272
+
273
+ ## Model Preparation
274
+
275
+ Models are not bundled — use the conversion scripts in `models/` to generate them.
276
+ These are **build-time scripts only** (run on x86/WSL2 with rknn-toolkit2); they are not
277
+ part of the pip package and are never deployed to the device.
278
+
279
+ ```
280
+ models/
281
+ ├── asr/qwen3/ # RKNN encoder, RKLLM decoder, matmul weights
282
+ ├── asr/paraformer/ # Paraformer RKNN conversion + hybrid-bucket export
283
+ ├── asr/sensevoice/ # SenseVoice RKNN export
284
+ ├── tts/matcha/ # Matcha+Vocos RKNN conversion + ONNX fixes
285
+ ├── tts/piper/ # Piper VITS split (CPU encoder + NPU decoder)
286
+ ├── tts/kokoro/ # Kokoro RKNN fixes
287
+ ├── tts/moss/ # MOSS-TTS island/bucket build, parity & smoke scripts
288
+ ├── rk1828/ # RK1828 PCIe coprocessor model production
289
+ └── common/ # Shared tools: Sin→polynomial, ScatterND bake, Erf→Tanh
290
+ ```
291
+
292
+ Expected model layout on the device:
293
+
294
+ ```
295
+ /opt/models/
296
+ ├── asr/
297
+ │ ├── encoder/rk3576/*.rknn
298
+ │ ├── decoder/rk3576/*.rkllm
299
+ │ ├── embed_tokens.npy
300
+ │ ├── mel_filters.npy
301
+ │ └── tokenizer.json
302
+ └── tts/rk3576/
303
+ ├── matcha.fp16.rknn
304
+ └── vocos.w4a16.rknn
305
+ ```
306
+
307
+ ## Configuration
308
+
309
+ Pre-validated profiles in `configs/`:
310
+
311
+ | Profile | Description |
312
+ |---------|-------------|
313
+ | `rk3576-full.yaml` | ASR + Matcha TTS (split NPU cores) |
314
+ | `rk3576-paraformer-matcha.yaml` | Paraformer RKNN ASR (hybrid encoder + RKNN decoder) + Matcha TTS |
315
+ | `rk3576-asr-only.yaml` | ASR with both NPU cores |
316
+ | `rk3576-tts-only.yaml` | Matcha TTS only |
317
+ | `rk3576-piper-multilang.yaml` | Piper multi-language TTS |
318
+ | `rk3588-full.yaml` | RK3588 full stack |
319
+ | `rk3588-paraformer-matcha.yaml` | RK3588 Paraformer RKNN ASR (hybrid encoder + RKNN decoder) + Matcha TTS |
320
+
321
+ Use via Docker:
322
+ ```bash
323
+ docker run -e CONFIG=rk3576-full rkvoice-stream
324
+ ```
325
+
326
+ Enable the validated Paraformer hybrid ASR container profile with an artifact
327
+ directory mounted at `/opt/asr/paraformer`. This uses RKNN encoder prefix,
328
+ CPU encoder suffix, and RKNN decoder:
329
+
330
+ ```bash
331
+ PARAFORMER_HOST_MODEL_DIR=/home/cat/models/paraformer-hybrid \
332
+ PARAFORMER_CONTAINER_RKNN_DIR=/opt/asr/paraformer/rknn/rk3576 \
333
+ docker compose -f docker/docker-compose.yml \
334
+ -f docker/docker-compose.paraformer-hybrid.yml \
335
+ --profile paraformer-hybrid up -d
336
+ ```
337
+
338
+ This profile uses the published arm64 image
339
+ `sensecraft-missionpack.seeed.cn/solution/seeed-local-voice:rk-v1.5-paraformer-hybrid`.
340
+ Published digest: `sha256:8dec7528ed4e08b919f0b2fd9192b8564d2b713df8552aed3eb98202c0a2c194`.
341
+ For RK3588 set `PARAFORMER_CONTAINER_RKNN_DIR=/opt/asr/paraformer/rknn/rk3588`.
342
+ Export/upload scripts live under `models/asr/paraformer/`; generated artifacts
343
+ are stored in the existing RK artifact repo under
344
+ `harvestsu/seeed-local-voice-rk-artifacts/rk3576/paraformer-hybrid/` and
345
+ `harvestsu/seeed-local-voice-rk-artifacts/rk3588/paraformer-hybrid/`.
346
+
347
+ Measured hybrid ASR performance uses the same Python pipeline baseline with
348
+ full ONNX Runtime vs RKNN prefix + ONNX suffix/decoder. RK3576 improved from
349
+ 0.58 RTF to 0.29 RTF, and RK3588 improved from 0.63 RTF to 0.33 RTF. The
350
+ actual `paraformer_rknn` backend entry measured 0.21 RTF on the 10.05s
351
+ validation sample on RK3576. The container profile has also been rebuilt and
352
+ validated on real RK3576/RK3588 devices with the same validation sample.
353
+
354
+ ## Testing
355
+
356
+ Dual-mode test suite — works against a live container or directly on device:
357
+
358
+ ```bash
359
+ # On device (direct mode)
360
+ pytest tests/ -v
361
+
362
+ # Against running container (HTTP mode)
363
+ SERVICE_URL=http://192.168.1.100:8621 pytest tests/ -v
364
+ ```
365
+
366
+ Quality gates: CER < 0.5 per sentence, RTF < 1.0.
367
+
368
+ ## Acknowledgements
369
+
370
+ Built on top of these projects:
371
+
372
+ - [sherpa-onnx](https://github.com/k2-fsa/sherpa-onnx) — speech inference engine (Piper, Kokoro, VAD)
373
+ - [Qwen3-TTS](https://github.com/QwenLM/Qwen3-TTS) — Qwen3 TTS model
374
+ - [Matcha-TTS](https://github.com/shivammehta25/Matcha-TTS) — non-autoregressive TTS
375
+ - [Piper](https://github.com/rhasspy/piper) — fast local neural TTS
376
+ - [RKNN-Toolkit2](https://github.com/airockchip/rknn-toolkit2) — Rockchip NPU SDK
377
+ - [RKLLM-Toolkit](https://github.com/airockchip/rkllm-toolkit) — Rockchip LLM SDK
378
+
379
+ ## License
380
+
381
+ [Apache-2.0](LICENSE)