Skip to content

Commit

Permalink
remove wait extra
Browse files Browse the repository at this point in the history
  • Loading branch information
robotaref committed Oct 30, 2023
1 parent 9381d33 commit 470a250
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 14 deletions.
14 changes: 5 additions & 9 deletions vocode/streaming/response_worker/random_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ async def process(self, item: InterruptableAgentResponseEvent[FillerAudio]):
filler_synthesis_result = filler_audio.create_synthesis_result()
self.current_filler_seconds_per_chunk = filler_audio.seconds_per_chunk
silence_threshold = (
self.config.silence_threshold_seconds + filler_audio.extra_wait_seconds
self.config.silence_threshold_seconds
)
await asyncio.sleep(silence_threshold)
self.filler_audio_started_event = threading.Event()
Expand Down Expand Up @@ -243,19 +243,15 @@ async def send_filler_audio(self, agent_response_tracker: Optional[asyncio.Event
"No filler audio available for synthesizer"
)

async def send_follow_up_audio(self, extra_wait_seconds: float, agent_response_tracker: Optional[asyncio.Event]):
async def send_follow_up_audio(self, agent_response_tracker: Optional[asyncio.Event]):
self.stop_all_audios()
if self.follow_up_worker is None:
return
self.logger.debug("Sending follow up audio")
assert self.follow_up_worker is not None
if self.conversation.synthesizer.follow_up_audios:
follow_up_audio = deepcopy(random.choice(self.conversation.synthesizer.follow_up_audios))
follow_up_audio.extra_wait_seconds = extra_wait_seconds
self.logger.debug(
f"Chose follow up audio, {follow_up_audio.message.text},"
f" with extra wait seconds: {follow_up_audio.extra_wait_seconds}"
)
self.logger.debug(f"Chose follow up audio, {follow_up_audio.message.text}")
event = self.conversation.interruptable_event_factory.create_interruptable_agent_response_event(
follow_up_audio,
is_interruptable=follow_up_audio.is_interruptable,
Expand Down Expand Up @@ -308,6 +304,6 @@ def sync_send_back_tracking_audio(self, agent_response_tracker: Optional[asyncio
loop = asyncio.get_event_loop()
loop.create_task(self.send_back_tracking_audio(agent_response_tracker))

def sync_send_follow_up_audio(self, extra_wait_seconds: float, agent_response_tracker: Optional[asyncio.Event]):
def sync_send_follow_up_audio(self, agent_response_tracker: Optional[asyncio.Event]):
loop = asyncio.get_event_loop()
loop.create_task(self.send_follow_up_audio(extra_wait_seconds, agent_response_tracker))
loop.create_task(self.send_follow_up_audio(agent_response_tracker))
5 changes: 2 additions & 3 deletions vocode/streaming/streaming_conversation.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,7 @@ async def process(self, item: InterruptableAgentResponseEvent[AgentResponse]):
self.conversation.random_audio_manager.sync_send_filler_audio(item.agent_response_tracker)
return
if isinstance(agent_response, AgentResponseFollowUpAudio):
self.conversation.random_audio_manager.sync_send_follow_up_audio(agent_response.seconds_spoken,
item.agent_response_tracker)
self.conversation.random_audio_manager.sync_send_follow_up_audio(item.agent_response_tracker)
return
if isinstance(agent_response, AgentResponseStop):
self.conversation.logger.debug("Agent requested to stop")
Expand Down Expand Up @@ -285,7 +284,7 @@ async def process(
self.conversation.logger.debug("Synthesis complete")
if self.input_queue.empty() and self.conversation.agent.get_agent_config().send_follow_up_audio:
self.conversation.agent.produce_interruptable_agent_response_event_nonblocking(
AgentResponseFollowUpAudio(seconds_spoken=0))
AgentResponseFollowUpAudio())

except asyncio.CancelledError:
pass
Expand Down
2 changes: 0 additions & 2 deletions vocode/streaming/synthesizer/base_synthesizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,12 @@ def __init__(
synthesizer_config: SynthesizerConfig,
is_interruptable: bool = False,
seconds_per_chunk: int = 1,
extra_wait_seconds: float = 0,
):
self.message = message
self.audio_data = audio_data
self.synthesizer_config = synthesizer_config
self.is_interruptable = is_interruptable
self.seconds_per_chunk = seconds_per_chunk
self.extra_wait_seconds = extra_wait_seconds

def create_synthesis_result(self) -> SynthesisResult:
chunk_size = (
Expand Down

0 comments on commit 470a250

Please sign in to comment.