feat(audio): 重构音频处理模块、音频流重采样测试成功

This commit is contained in:
himeditator
2025-07-07 00:47:36 +08:00
parent f2aa075e65
commit 0696651f04
11 changed files with 253 additions and 115 deletions

View File

@@ -8,7 +8,7 @@ elif sys.platform == 'linux':
else:
raise NotImplementedError(f"Unsupported platform: {sys.platform}")
from audioprcs import mergeStreamChannels
from audioprcs import mergeChunkChannels
from audio2text import InvalidParameter, GummyTranslator
@@ -26,13 +26,13 @@ def convert_audio_to_text(s_lang, t_lang, audio_type):
while True:
try:
data = stream.read_chunk()
data = mergeStreamChannels(data, stream.CHANNELS)
chunk = stream.read_chunk()
chunk_mono = mergeChunkChannels(chunk, stream.CHANNELS)
try:
gummy.send_audio_frame(data)
gummy.send_audio_frame(chunk_mono)
except InvalidParameter:
gummy.start()
gummy.send_audio_frame(data)
gummy.send_audio_frame(chunk_mono)
except KeyboardInterrupt:
stream.closeStream()
gummy.stop()