Indic Parler-TTS 是基于 Parler-TTS Mini 的多语言 Indic 扩展,支持 21 种语言(英语 + 20 种印度语言),使用 DAC 44.1kHz 声码器与 Flan-T5-Large 文本编码器,解码器为 24 层 Transformer (1024 hidden, 9 codebooks, delay 模式)。官方权重: https://huggingface.co/ai4bharat/indic-parler-tts, 采样率 44100 Hz。
ParlerTTSForConditionalGeneration (parler_tts 0.2.2) + T5EncoderModel (Flan-T5) + DacModel (DAC 44kHz)prompt (待合成文本) + description (音色/风格描述,例如 "A female speaker delivers a slightly expressive...")tokenizer.json (prompt, 90714 vocab) + google/flan-t5-large (description, 32128 vocab)npu:0 (torch.npu.is_available()==True, device_count=2, device_name=Ascend910_9362)pip install -r requirements.txt
# 需预先安装 CANN 8.5.1 与 torch_npu 2.9.0,Ascend 910/910B/910C 需对应版本
# parler_tts 需配合 descript-audio-codec 1.0.0 + descript-audiotools 0.7.2 (已包含 DAC 权重)# 默认 (NPU, 真实文本+描述)
python inference.py --device npu:0
# 指定文本与描述
python inference.py --device npu:0 --prompt "Hey, how are you doing today?" --description "A female speaker delivers a slightly expressive and animated speech with a moderate speed and pitch. The recording is of very high quality, with the speaker's voice sounding clear and very close up." --output /tmp/indic_npu.wav
# CPU 基线 (一致性对照)
python inference.py --device cpu --output /tmp/indic_cpu.wav
# 额外性能压测 (3 次稳定推理)
python inference.py --device npu:0 --benchmark 1关键适配:
randomname, argbind, torch.utils.tensorboard 以支持离线环境下 dac/audiotools 导入 (无需完整 tensorboard)torch.npu.synchronize() 包裹 model.generate() 计时,区分首次编译与稳定推理do_sample=False, temperature=1.0, seed 42 固定随机性,prompts 与 description 完全一致用于 CPU-NPU 对比fake_tb 本地 tensorboard 兼容层避免 torch.utils.tensorboard 缺失导致的导入失败SlidingWindowCache 前签名Hey, how are you doing today? (9 tokens) + Description 42 tokensnpu:0, input_ids npu:0, output waveform npu:0 (三处均记录)示例日志 (NPU):
[ENV] torch 2.9.0+cpu torch_npu available torch_npu_available=True device_count=2 device_name=Ascend910_9362
[NPU-SMI] Ascend910 910_9362 Power 167W Temp 47C HBM 3112/65536 MB
[DEVICE] model param device: npu:0
[INPUT] prompt_input_ids device: npu:0 shape torch.Size([1, 9])
[INPUT] description_input_ids device: npu:0 shape torch.Size([1, 42])
[GEN] generation device: npu:0 shape torch.Size([1, 1331712]) dtype torch.float32
[PERF] latency_ms=56753.98 (synchronized) npu_synchronized=True
[OUTPUT] waveform shape (1331712,) sr 44100 duration 30.20s
[STATS] finite_ratio=1.0000 rms=0.0417 peak=0.3090 clipping_ratio=0.0000 silence_ratio=0.0120
[SAVE] saved to /tmp/indic_npu.wav sr=44100 samples=1331712 duration=30.20s
[BENCH] latency_ms 56753.98 audio_duration_sec 30.20 RTF 1.880 chars/s 0.48
[DONE] device proof: model param npu:0, input npu:0, output npu:0 (all should be npu:0)torch.npu.synchronize() 前后, 含首次编译assets/agent_workflow.png: 端到端工作流 (环境检查->获取模型->分析模型->NPU适配->NPU验证->整理仓库->推送GitCode)assets/npu_device_call.png: npu-smi 与 torch.npu 设备调用证明 (含 model param/input/output 三处 npu:0)assets/model_result.png: 真实推理结果与指标 (含 waveform stats, latency, RTF, 保存路径)Hardware: NPU, Ascend910, Parler-TTS
