Delete tts/onnx_runner.py
Browse files- tts/onnx_runner.py +0 -45
tts/onnx_runner.py
DELETED
|
@@ -1,45 +0,0 @@
|
|
| 1 |
-
import onnxruntime as ort
|
| 2 |
-
import numpy as np
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
class MOSSOnnxTTS:
|
| 6 |
-
def __init__(self, model_dir):
|
| 7 |
-
self.model_dir = model_dir
|
| 8 |
-
|
| 9 |
-
# CPU ONNX Runtime
|
| 10 |
-
self.session = ort.InferenceSession(
|
| 11 |
-
f"{model_dir}/moss_tts_prefill.onnx",
|
| 12 |
-
providers=["CPUExecutionProvider"]
|
| 13 |
-
)
|
| 14 |
-
|
| 15 |
-
self.decoder = ort.InferenceSession(
|
| 16 |
-
f"{model_dir}/moss_tts_decode_step.onnx",
|
| 17 |
-
providers=["CPUExecutionProvider"]
|
| 18 |
-
)
|
| 19 |
-
|
| 20 |
-
def infer(self, text, prompt_audio_path):
|
| 21 |
-
"""
|
| 22 |
-
简化版 pipeline(实际项目可扩展 tokenizer + codec)
|
| 23 |
-
"""
|
| 24 |
-
|
| 25 |
-
# ⚠️ 这里是占位逻辑(重点是架构)
|
| 26 |
-
# 实际需要:
|
| 27 |
-
# 1. text -> tokens
|
| 28 |
-
# 2. prompt audio -> speaker embedding
|
| 29 |
-
# 3. autoregressive decode
|
| 30 |
-
# 4. audio tokenizer decode
|
| 31 |
-
|
| 32 |
-
tokens = np.array([1, 2, 3], dtype=np.int64) # placeholder
|
| 33 |
-
|
| 34 |
-
outputs = self.session.run(
|
| 35 |
-
None,
|
| 36 |
-
{
|
| 37 |
-
"input_ids": tokens
|
| 38 |
-
}
|
| 39 |
-
)
|
| 40 |
-
|
| 41 |
-
# fake waveform(你需要替换成 codec decode)
|
| 42 |
-
wav = np.random.randn(16000 * 3).astype(np.float32)
|
| 43 |
-
|
| 44 |
-
sr = 16000
|
| 45 |
-
return wav, sr
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|