alphacep / vosk-api

Offline speech recognition API for Android, iOS, Raspberry Pi and servers with Python, Java, C# and Node
Apache License 2.0
7.7k stars 1.08k forks source link

Error opening RawInputStream: Unanticipated host error [PaErrorCode -9999] #1281

Closed ben-8878 closed 1 year ago

ben-8878 commented 1 year ago

run test_microphonepy script,get follow errors:

E:\code\asr-demo\python\example>python test_microphone2.py -m model -r 16000 -d 0
LOG (VoskAPI:ReadDataFiles():model.cc:206) Decoding params beam=12 max-active=7000 lattice-beam=6
LOG (VoskAPI:ReadDataFiles():model.cc:209) Silence phones 1:2:3:4:5:6:7:8:9:10
LOG (VoskAPI:RemoveOrphanNodes():nnet-nnet.cc:948) Removed 0 orphan nodes.
LOG (VoskAPI:RemoveOrphanComponents():nnet-nnet.cc:847) Removing 0 orphan components.
LOG (VoskAPI:CompileLooped():nnet-compile-looped.cc:345) Spent 0.0886221 seconds in looped compilation.
LOG (VoskAPI:ReadDataFiles():model.cc:233) Loading i-vector extractor from model/ivector/final.ie
LOG (VoskAPI:ComputeDerivedVars():ivector-extractor.cc:183) Computing derived variables for iVector extractor
LOG (VoskAPI:ComputeDerivedVars():ivector-extractor.cc:204) Done.
LOG (VoskAPI:ReadDataFiles():model.cc:263) Loading HCLG from model/graph/HCLG.fst
LOG (VoskAPI:ReadDataFiles():model.cc:278) Loading words from model/graph/words.txt
PortAudioError: Error opening RawInputStream: Unanticipated host error [PaErrorCode -9999]: '无效的参数被传递给一个系统功能 。' [MME error 11]
nshmyrev commented 1 year ago

Try to leave the rate default or 44100, some windows drivers can't resample

ben-8878 commented 1 year ago

Try to leave the rate default or 44100, some windows drivers can't resample

it does not work, test with follow codes:

import sounddevice as sd
sd.default.device[0] = 1
fs = 44100 # Hz
length = 5 # s
recording = sd.rec(frames=fs * length, samplerate=fs, blocking=True, channels=1)
from scipy.io import wavfile
wavfile.write('recording.wav', fs, recording)
nshmyrev commented 1 year ago

Maybe it wants two channels or wrong device id. It is not really Vosk issue, you have just problem recording audio.

ben-8878 commented 1 year ago

this is a bug of sounddevice , set utf8 coding in windows, it will met the errors; unset utf8 coding in windows,it will met UnicodeDecodeError:utf-8 error. above error may happen in some pc, not all windows pc met those error.

ben-8878 commented 1 year ago

sorry,the error was blocked by antivirus software, I close it.