liumaolin commited on
Commit
5284873
·
1 Parent(s): bba0d84

Refactor speech processing: add type hint for `_process_active_voice_frame` and replace `max()` with `np.max()` for consistency.

Browse files
src/VoiceDialogue/services/speech/speech_monitor.py CHANGED
@@ -111,7 +111,7 @@ class SpeechStateMonitor(BaseThread):
111
  """计算音频帧时长(毫秒)"""
112
  return librosa.get_duration(y=audio_frame, sr=self.sample_rate) * 1000
113
 
114
- def _process_active_voice_frame(self, audio_frame):
115
  """
116
  处理活跃语音帧
117
 
@@ -121,7 +121,7 @@ class SpeechStateMonitor(BaseThread):
121
  Returns:
122
  bool: 是否为有效的活跃语音帧
123
  """
124
- if audio_frame.max() <= self.config.MIN_AUDIO_AMPLITUDE:
125
  return False
126
 
127
  # 重置静音计时
 
111
  """计算音频帧时长(毫秒)"""
112
  return librosa.get_duration(y=audio_frame, sr=self.sample_rate) * 1000
113
 
114
+ def _process_active_voice_frame(self, audio_frame: np.ndarray):
115
  """
116
  处理活跃语音帧
117
 
 
121
  Returns:
122
  bool: 是否为有效的活跃语音帧
123
  """
124
+ if np.max(audio_frame) <= self.config.MIN_AUDIO_AMPLITUDE:
125
  return False
126
 
127
  # 重置静音计时