Open flylinux opened 1 month ago
This issue causes data errors in the buffer when running the example at https://k2-fsa.github.io/sherpa/onnx/tts/pretrained_models/vits.html#generate-speech-with-python-script, resulting in no sound output.
Install the test environment
conda create -n sherpa-onnx python=3.12 conda activate sherpa-onnx pip install sherpa-onnx sounddevice soundfile numpy
The following code returns no output in numpy 2.x, but normally in numpy 1.x:
import sherpa_onnx import numpy as np def generated_audio_callback(samples: np.ndarray, progress: float): print("输出接受的音频数据(与第一个接受到的相同则不输出)") for i in range(len(samples)): if samples[i] != samples[0]: print(f"recv msg: {i} {samples[i]}") return 1 tts_config = sherpa_onnx.OfflineTtsConfig( model=sherpa_onnx.OfflineTtsModelConfig( vits=sherpa_onnx.OfflineTtsVitsModelConfig( model="./vits-piper-en_US-amy-low/en_US-amy-low.onnx", lexicon="", data_dir="./vits-piper-en_US-amy-low/espeak-ng-data", dict_dir="", tokens="./vits-piper-en_US-amy-low/tokens.txt", ), provider="cpu", debug=True, num_threads=1, ), rule_fsts="", max_num_sentences=1, ) tts = sherpa_onnx.OfflineTts(tts_config) audio = tts.generate( "Today as always, men fall into two groups: slaves and free men.", sid=0, speed=1, callback=generated_audio_callback )
Solution:
pip install numpy=1.26.4
You have no idea how much I could thank you so much for that. I wish I looked here earlier - ive been convinced my problem is something in my flaky code when in fact it was this. Hero.
This issue causes data errors in the buffer when running the example at https://k2-fsa.github.io/sherpa/onnx/tts/pretrained_models/vits.html#generate-speech-with-python-script, resulting in no sound output.
Install the test environment
The following code returns no output in numpy 2.x, but normally in numpy 1.x:
Solution: