Loading...
Loading...
Compare original and translation side by side
Skill by ara.so — Daily 2026 Skills collection.
技能由 ara.so 提供 — 属于Daily 2026 Skills合集。
conda create -n moss-tts-nano python=3.12 -y
conda activate moss-tts-nano
git clone https://github.com/OpenMOSS/MOSS-TTS-Nano.git
cd MOSS-TTS-Nano
pip install -r requirements.txt
pip install -e .conda create -n moss-tts-nano python=3.12 -y
conda activate moss-tts-nano
git clone https://github.com/OpenMOSS/MOSS-TTS-Nano.git
cd MOSS-TTS-Nano
pip install -r requirements.txt
pip install -e .conda install -c conda-forge pynini=2.1.6.post1 -y
pip install git+https://github.com/WhizZest/WeTextProcessing.gitpip install -e .moss-tts-nanoconda install -c conda-forge pynini=2.1.6.post1 -y
pip install git+https://github.com/WhizZest/WeTextProcessing.gitpip install -e .moss-tts-nanoOpenMOSS-Team/MOSS-TTS-NanoOpenMOSS-Team/MOSS-Audio-Tokenizer-Nanoopenmoss/MOSS-TTS-Nanoopenmoss/MOSS-Audio-Tokenizer-NanoOpenMOSS-Team/MOSS-TTS-NanoOpenMOSS-Team/MOSS-Audio-Tokenizer-Nanoopenmoss/MOSS-TTS-Nanoopenmoss/MOSS-Audio-Tokenizer-Nanomoss-tts-nano generate \
--prompt-speech assets/audio/zh_1.wav \
--text "欢迎关注模思智能、上海创智学院与复旦大学自然语言处理实验室。"generated_audio/moss_tts_nano_output.wavmoss-tts-nano generate \
--prompt-speech assets/audio/zh_1.wav \
--text "欢迎关注模思智能、上海创智学院与复旦大学自然语言处理实验室。"generated_audio/moss_tts_nano_output.wavmoss-tts-nano generate \
--prompt-speech assets/audio/zh_1.wav \
--text-file my_script.txt \
--output output.wavmoss-tts-nano generate \
--prompt-speech assets/audio/zh_1.wav \
--text-file my_script.txt \
--output output.wavmoss-tts-nano servemoss-tts-nano serve
Opens at `http://127.0.0.1:18083` — model stays loaded in memory for fast repeated requests.
将在`http://127.0.0.1:18083`打开 — 模型会保持加载在内存中,以支持快速重复请求。python infer.py \
--prompt-audio-path assets/audio/zh_1.wav \
--text "Hello, this is a test of MOSS-TTS-Nano."generated_audio/infer_output.wavpython infer.py \
--prompt-audio-path assets/audio/zh_1.wav \
--text "Hello, this is a test of MOSS-TTS-Nano."generated_audio/infer_output.wavfrom infer import MossTTSNanoInferencefrom infer import MossTTSNanoInferenceundefinedundefinedfrom infer import MossTTSNanoInference
tts = MossTTSNanoInference()
audio = tts.infer(
text="Welcome to MOSS TTS Nano, a tiny but capable text to speech model.",
prompt_audio_path="assets/audio/en_sample.wav",
)
import soundfile as sf
sf.write("english_output.wav", audio, samplerate=48000)from infer import MossTTSNanoInference
tts = MossTTSNanoInference()
audio = tts.infer(
text="Welcome to MOSS TTS Nano, a tiny but capable text to speech model.",
prompt_audio_path="assets/audio/en_sample.wav",
)
import soundfile as sf
sf.write("english_output.wav", audio, samplerate=48000)from infer import MossTTSNanoInference
import soundfile as sf
import numpy as np
tts = MossTTSNanoInference()
chunks = []
for audio_chunk in tts.infer_stream(
text="This sentence is generated chunk by chunk for low latency playback.",
prompt_audio_path="assets/audio/en_sample.wav",
):
chunks.append(audio_chunk)
# process or play chunk in real time here
full_audio = np.concatenate(chunks)
sf.write("streamed_output.wav", full_audio, samplerate=48000)from infer import MossTTSNanoInference
import soundfile as sf
import numpy as np
tts = MossTTSNanoInference()
chunks = []
for audio_chunk in tts.infer_stream(
text="This sentence is generated chunk by chunk for low latency playback.",
prompt_audio_path="assets/audio/en_sample.wav",
):
chunks.append(audio_chunk)
# 在此处实时处理或播放片段
full_audio = np.concatenate(chunks)
sf.write("streamed_output.wav", full_audio, samplerate=48000)from infer import MossTTSNanoInference
tts = MossTTSNanoInference()
long_text = """
MOSS-TTS-Nano supports long-form synthesis through automatic chunking.
Each chunk uses the same reference voice, producing consistent speaker identity
across the entire output even for multi-paragraph documents.
"""
audio = tts.infer(
text=long_text,
prompt_audio_path="assets/audio/en_sample.wav",
)
import soundfile as sf
sf.write("long_form_output.wav", audio, samplerate=48000)from infer import MossTTSNanoInference
tts = MossTTSNanoInference()
long_text = """
MOSS-TTS-Nano支持通过自动分段实现长文本合成。
每个分段使用相同的参考音色,即使是多段落文档,整个输出的说话人身份也能保持一致。
"""
audio = tts.infer(
text=long_text,
prompt_audio_path="assets/audio/en_sample.wav",
)
import soundfile as sf
sf.write("long_form_output.wav", audio, samplerate=48000)moss-tts-nano servepython app.pyimport requests
import base64
import soundfile as sf
import io
import numpy as npmoss-tts-nano servepython app.pyimport requests
import base64
import soundfile as sf
import io
import numpy as npundefinedundefinedimport requests
with open("assets/audio/zh_1.wav", "rb") as f:
ref_audio_b64 = __import__("base64").b64encode(f.read()).decode()
with requests.post(
"http://127.0.0.1:18083/generate_stream",
json={
"text": "流式语音合成示例,适合实时播放场景。",
"prompt_audio_base64": ref_audio_b64,
},
stream=True,
) as resp:
with open("stream_output.wav", "wb") as out:
for chunk in resp.iter_content(chunk_size=4096):
out.write(chunk)import requests
with open("assets/audio/zh_1.wav", "rb") as f:
ref_audio_b64 = __import__("base64").b64encode(f.read()).decode()
with requests.post(
"http://127.0.0.1:18083/generate_stream",
json={
"text": "流式语音合成示例,适合实时播放场景。",
"prompt_audio_base64": ref_audio_b64,
},
stream=True,
) as resp:
with open("stream_output.wav", "wb") as out:
for chunk in resp.iter_content(chunk_size=4096):
out.write(chunk)| Code | Language | Code | Language | Code | Language |
|---|---|---|---|---|---|
| zh | Chinese | en | English | de | German |
| es | Spanish | fr | French | ja | Japanese |
| it | Italian | hu | Hungarian | ko | Korean |
| ru | Russian | fa | Persian | ar | Arabic |
| pl | Polish | pt | Portuguese | cs | Czech |
| da | Danish | sv | Swedish | el | Greek |
| tr | Turkish |
| 代码 | 语言 | 代码 | 语言 | 代码 | 语言 |
|---|---|---|---|---|---|
| zh | 中文 | en | 英文 | de | 德语 |
| es | 西班牙语 | fr | 法语 | ja | 日语 |
| it | 意大利语 | hu | 匈牙利语 | ko | 韩语 |
| ru | 俄语 | fa | 波斯语 | ar | 阿拉伯语 |
| pl | 波兰语 | pt | 葡萄牙语 | cs | 捷克语 |
| da | 丹麦语 | sv | 瑞典语 | el | 希腊语 |
| tr | 土耳其语 |
| Flag | Alias | Description |
|---|---|---|
| — | Path to reference WAV for voice cloning ( |
| — | Same purpose in |
| — | Input text string |
| — | Path to plain text file for long-form synthesis |
| — | Output WAV file path (default varies by entrypoint) |
| 参数 | 别名 | 描述 |
|---|---|---|
| — | 用于语音克隆的参考WAV文件路径( |
| — | 在 |
| — | 输入文本字符串 |
| — | 用于长文本合成的纯文本文件路径 |
| — | 输出WAV文件路径(默认路径因入口点而异) |
from infer import MossTTSNanoInference
import soundfile as sf
tts = MossTTSNanoInference()
ref = "assets/audio/zh_1.wav"
sentences = [
"第一句话,用于批量合成测试。",
"第二句话,保持相同的音色。",
"第三句话,输出独立的音频文件。",
]
for i, sentence in enumerate(sentences):
audio = tts.infer(text=sentence, prompt_audio_path=ref)
sf.write(f"output_{i:02d}.wav", audio, samplerate=48000)
print(f"Saved output_{i:02d}.wav")from infer import MossTTSNanoInference
import soundfile as sf
tts = MossTTSNanoInference()
ref = "assets/audio/zh_1.wav"
sentences = [
"第一句话,用于批量合成测试。",
"第二句话,保持相同的音色。",
"第三句话,输出独立的音频文件。",
]
for i, sentence in enumerate(sentences):
audio = tts.infer(text=sentence, prompt_audio_path=ref)
sf.write(f"output_{i:02d}.wav", audio, samplerate=48000)
print(f"已保存output_{i:02d}.wav")import sounddevice as sd
import numpy as np
from infer import MossTTSNanoInference
tts = MossTTSNanoInference()
buffer = []
for chunk in tts.infer_stream(
text="Real-time playback example using sounddevice.",
prompt_audio_path="assets/audio/en_sample.wav",
):
buffer.append(chunk)
audio = np.concatenate(buffer)
sd.play(audio, samplerate=48000)
sd.wait()import sounddevice as sd
import numpy as np
from infer import MossTTSNanoInference
tts = MossTTSNanoInference()
buffer = []
for chunk in tts.infer_stream(
text="Real-time playback example using sounddevice.",
prompt_audio_path="assets/audio/en_sample.wav",
):
buffer.append(chunk)
audio = np.concatenate(buffer)
sd.play(audio, samplerate=48000)
sd.wait()import gradio as gr
import soundfile as sf
import numpy as np
import io
from infer import MossTTSNanoInference
tts = MossTTSNanoInference()
def synthesize(reference_audio_path: str, text: str):
audio = tts.infer(text=text, prompt_audio_path=reference_audio_path)
# Return as (sample_rate, numpy_array) tuple for Gradio Audio component
return (48000, audio)
demo = gr.Interface(
fn=synthesize,
inputs=[
gr.Audio(type="filepath", label="Reference Voice"),
gr.Textbox(label="Text to synthesize"),
],
outputs=gr.Audio(label="Generated Speech"),
title="MOSS-TTS-Nano Voice Clone",
)
demo.launch()import gradio as gr
import soundfile as sf
import numpy as np
import io
from infer import MossTTSNanoInference
tts = MossTTSNanoInference()
def synthesize(reference_audio_path: str, text: str):
audio = tts.infer(text=text, prompt_audio_path=reference_audio_path)
# 返回(sample_rate, numpy_array)元组给Gradio Audio组件
return (48000, audio)
demo = gr.Interface(
fn=synthesize,
inputs=[
gr.Audio(type="filepath", label="参考音色"),
gr.Textbox(label="待合成文本"),
],
outputs=gr.Audio(label="生成语音"),
title="MOSS-TTS-Nano语音克隆",
)
demo.launch()undefinedundefinedundefinedundefinedHF_ENDPOINTexport HF_ENDPOINT=https://hf-mirror.com
python infer.py --prompt-audio-path assets/audio/zh_1.wav --text "测试"pip install modelscopeopenmoss/MOSS-TTS-Nanoopenmoss/MOSS-Audio-Tokenizer-NanoHF_ENDPOINTexport HF_ENDPOINT=https://hf-mirror.com
python infer.py --prompt-audio-path assets/audio/zh_1.wav --text "测试"pip install modelscopeopenmoss/MOSS-TTS-Nanoopenmoss/MOSS-Audio-Tokenizer-Nanoinfer_streaminfer_streammoss-tts-nanomoss-tts-nanoundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefined| Entrypoint | Default output path |
|---|---|
| |
| |
| returned via HTTP response |
generated_audio/| 入口点 | 默认输出路径 |
|---|---|
| |
| |
| 通过HTTP响应返回 |
generated_audio/