目錄
- 1. 問題報錯
- 2. 解決方法
1. 問題報錯
報錯:
An overrun occurred, which means the RTF of the current model on your board is larger than 1. You can use ./bin/sherpa-ncnn to verify that. Please select a smaller model whose RTF is less than 1 for your board.
問題:
這個錯誤表明音頻處理速度跟不上音頻采集速度,導致緩沖區溢出。
-
具體是,調用sherpa-ncnn-alsa_Test時,音頻是實時采集的,在采集到音頻后會對音頻數據進行額外處理。
-
例如:將音頻轉出來的文字,組成句子,傳輸給其他API調用。
-
在其他API處理這個句子時,語音還在實時采集,這是就會導致處理速度跟不上音頻采集速度。
解決思路:
在音頻額外處理期間,停止音頻識別采集,在運行結束時恢復音頻識別采集,以避免數據溢出。
2. 解決方法
音頻處理速度跟不上音頻采集速度時。在音頻額外處理期間,停止音頻識別采集,在運行結束時恢復音頻識別采集。
- 以為調用
audio_op()
對音頻進行處理為例;
(1)修改 sherpa-ncnn/csrc/alsa.h
:
-
在
Alsa
類中,添加暫停和恢復音頻采集的功能,即Pause()
和Resume()
方法。 -
使用 ALSA 的
snd_pcm_pause
函數來正確暫停和恢復音頻采集;
class Alsa {public:// ... code ...// 添加暫停和恢復方法// 使用 ALSA 的 snd_pcm_pause 函數來正確暫停和恢復音頻采集void Pause() { snd_pcm_pause(capture_handle_, 1); }void Resume() { snd_pcm_pause(capture_handle_, 0); }// ... code ...
};
(2)修改 sherpa-ncnn/csrc/sherpa-ncnn-alsa.cc
:
- 使用暫停和恢復音頻采集的功能
// ... code ...while (!stop) {// ... code ...if (is_endpoint) {if (!text.empty()) {++segment_index;alsa.Pause(); // 暫停音頻采集audio_op(); // 音頻處理操作alsa.Resume(); // 恢復音頻采集}recognizer.Reset(s.get());}}
.
聲明:資源可能存在第三方來源,若有侵權請聯系刪除!