Skip to content

Commit

Permalink
fix: Text stream split by sentences
Browse files Browse the repository at this point in the history
  • Loading branch information
clemlesne committed Jan 26, 2024
1 parent b11ad6f commit 43221aa
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@

CALL_EVENT_URL = f'{CONFIG.api.events_domain.strip("/")}/call/event'
CALL_INBOUND_URL = f'{CONFIG.api.events_domain.strip("/")}/call/inbound'
SENTENCE_R = r"[^\w\s\-',:;()]"
SENTENCE_R = r"[^\w\s\-/',:;()]"
MESSAGE_ACTION_R = rf"(?:{'|'.join([action.value for action in MessageAction])}):"


Expand Down Expand Up @@ -471,7 +471,7 @@ async def gpt_callback(text: str) -> None:
content=CONFIG.prompts.tts.error(), intent=IndentAction.CONTINUE
)

_logger.info(f"Chat ({call.call_id}): {chat_action}")
_logger.debug(f"Chat ({call.call_id}): {chat_action}")

if chat_action.intent == IndentAction.TALK_TO_HUMAN:
await handle_play(
Expand Down Expand Up @@ -527,6 +527,8 @@ async def handle_play(
MessageModel(content=text, persona=MessagePersona.ASSISTANT)
)

_logger.info(f"Playing text ({call.call_id}): {text}")

# Split text in chunks of max 400 characters, separated by a comma
chunks = []
chunk = ""
Expand Down

0 comments on commit 43221aa

Please sign in to comment.