解决 Audio data must be floating-point - #29
Merged
Merged
Conversation
|
zhouzhenneng seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
在魔塔在线体验和本地部署之后,上传wav音频,均遇到如下报错:
File "funclip/launch.py", line 21, in audio_recog
return audio_clipper.recog(audio_input, sd_switch, hotwords=hotwords)
File "/root/FunClip/FunClip/funclip/videoclipper.py", line 30, in recog
data = librosa.resample(data, orig_sr=sr, target_sr=16000)
File "/root/miniconda3/envs/funclip/lib/python3.8/site-packages/librosa/core/audio.py", line 627, in resample
util.valid_audio(y, mono=False)
File "/root/miniconda3/envs/funclip/lib/python3.8/site-packages/librosa/util/utils.py", line 298, in valid_audio
raise ParameterError("Audio data must be floating-point")
librosa.util.exceptions.ParameterError: Audio data must be floating-point
这段报错,主要是librosa 在处理音频数据时期望浮点型数据,但接收到的可能是整型数据(例如int16)。librosa 处理音频时,音频数据需要是浮点数格式,通常范围在 -1.0 到 1.0,所以增加了convert_pcm_to_float 函数将音频转成浮点数