Not creating InputAudioRawFrame in case we don't have bytes.
This commit is contained in:
@@ -13,7 +13,11 @@ from typing import Optional
|
|||||||
from loguru import logger
|
from loguru import logger
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
|
|
||||||
from pipecat.audio.utils import create_stream_resampler, pcm_to_ulaw, ulaw_to_pcm
|
from pipecat.audio.utils import (
|
||||||
|
create_stream_resampler,
|
||||||
|
pcm_to_ulaw,
|
||||||
|
ulaw_to_pcm,
|
||||||
|
)
|
||||||
from pipecat.frames.frames import (
|
from pipecat.frames.frames import (
|
||||||
AudioRawFrame,
|
AudioRawFrame,
|
||||||
CancelFrame,
|
CancelFrame,
|
||||||
@@ -235,6 +239,10 @@ class TwilioFrameSerializer(FrameSerializer):
|
|||||||
deserialized_data = await ulaw_to_pcm(
|
deserialized_data = await ulaw_to_pcm(
|
||||||
payload, self._twilio_sample_rate, self._sample_rate, self._input_resampler
|
payload, self._twilio_sample_rate, self._sample_rate, self._input_resampler
|
||||||
)
|
)
|
||||||
|
if deserialized_data is None or len(deserialized_data) == 0:
|
||||||
|
# Ignoring in case we don't have audio
|
||||||
|
return None
|
||||||
|
|
||||||
audio_frame = InputAudioRawFrame(
|
audio_frame = InputAudioRawFrame(
|
||||||
audio=deserialized_data, num_channels=1, sample_rate=self._sample_rate
|
audio=deserialized_data, num_channels=1, sample_rate=self._sample_rate
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -152,6 +152,13 @@ class STTService(AIService):
|
|||||||
else:
|
else:
|
||||||
self._user_id = ""
|
self._user_id = ""
|
||||||
|
|
||||||
|
if not frame.audio:
|
||||||
|
# Ignoring in case we don't have audio to transcribe.
|
||||||
|
logger.warning(
|
||||||
|
f"Empty audio frame received for STT service: {self.name} {frame.num_frames}"
|
||||||
|
)
|
||||||
|
return
|
||||||
|
|
||||||
await self.process_generator(self.run_stt(frame.audio))
|
await self.process_generator(self.run_stt(frame.audio))
|
||||||
|
|
||||||
async def process_frame(self, frame: Frame, direction: FrameDirection):
|
async def process_frame(self, frame: Frame, direction: FrameDirection):
|
||||||
|
|||||||
Reference in New Issue
Block a user