Merge pull request #4 from Plaud-AI/feat/demo

feat: fix pcm
This commit is contained in:
Harold-Guo 2025-11-10 19:05:35 +08:00 committed by GitHub
commit 5bec5d2549
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -12,7 +12,8 @@ from io import BytesIO
from core.utils import p3 from core.utils import p3
from pydub import AudioSegment from pydub import AudioSegment
from typing import Callable, Any from typing import Callable, Any
from config.logger import setup_logging
logger = setup_logging()
TAG = __name__ TAG = __name__
emoji_map = { emoji_map = {
"neutral": "😶", "neutral": "😶",
@ -317,13 +318,12 @@ def audio_bytes_to_data_stream(audio_bytes, file_type, is_opus, callback: Callab
""" """
transfer audio bytes to opus/pcm data, support wav、mp3、p3、pcm transfer audio bytes to opus/pcm data, support wav、mp3、p3、pcm
""" """
logger.bind(tag=TAG).info(f"audio_bytes_to_data_stream: {file_type}")
if file_type == "p3": if file_type == "p3":
# 直接用p3解码 # 直接用p3解码
return p3.decode_opus_from_bytes_stream(audio_bytes, callback) return p3.decode_opus_from_bytes_stream(audio_bytes, callback)
elif file_type == "pcm": elif file_type == "pcm":
audio = AudioSegment.from_raw( return pcm_to_data_stream(audio_bytes, is_opus, callback)
BytesIO(audio_bytes),
)
else: else:
# other formats use pydub # other formats use pydub
audio = AudioSegment.from_file( audio = AudioSegment.from_file(