Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: turn based conversation playground fails execution #742

Open
matteo-ticli opened this issue Jan 21, 2025 · 0 comments
Open

[Bug]: turn based conversation playground fails execution #742

matteo-ticli opened this issue Jan 21, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@matteo-ticli
Copy link

matteo-ticli commented Jan 21, 2025

Brief Description

I am new to the repo and I am trying it out. I have encountered a bug using the following code:

import asyncio
import signal

from pydantic_settings import BaseSettings, SettingsConfigDict

from vocode.helpers import create_streaming_microphone_input_and_speaker_output, \
    create_turn_based_microphone_input_and_speaker_output
from vocode.logging import configure_pretty_logging
from vocode.turn_based.agent.chat_gpt_agent import ChatGPTAgent
from vocode.turn_based.synthesizer.eleven_labs_synthesizer import ElevenLabsSynthesizer
from vocode.turn_based.transcriber.whisper_transcriber import WhisperTranscriber
from vocode.turn_based.turn_based_conversation import TurnBasedConversation

configure_pretty_logging()


class Settings(BaseSettings):
    """
    Settings for the turn-based conversation quickstart.
    These parameters can be configured with environment variables.
    """
    model_config = SettingsConfigDict(
        env_file=".env",
        env_file_encoding="utf-8",
    )

    # Define environment variables
    deepgram_api_key: str
    openai_api_key: str
    elevenlabs_api_key: str


settings = Settings()

if __name__ == "__main__":
    (
        microphone_input,
        speaker_output,
    ) = create_turn_based_microphone_input_and_speaker_output(
        use_default_devices=True,
    )

    conversation = TurnBasedConversation(
        input_device=microphone_input,
        output_device=speaker_output,
        transcriber=WhisperTranscriber(api_key=settings.openai_api_key),
        agent=ChatGPTAgent(
            api_key=settings.openai_api_key,
            system_prompt="The AI is having a pleasant conversation about life",
            initial_message="Hello!",
        ),
        synthesizer=ElevenLabsSynthesizer(
            api_key=settings.elevenlabs_api_key,
            voice_id="Lhvb6ub1gbURNYItrKHe",
            stability=0.75,
            similarity_boost=0.5
        )
    )
    print("Starting conversation. Press Ctrl+C to exit.")
    while True:
        try:
            input("Press enter to start recording...")
            conversation.start_speech()
            input("Press enter to end recording...")
            conversation.end_speech_and_respond()
        except KeyboardInterrupt:
            break

The error message is the following:

Traceback (most recent call last):
  File "/Users/matteoticli/coding_projects/AIphone/AIphone/test_turn_conversation.py", line 47, in <module>
    conversation = TurnBasedConversation(
                   ^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/matteoticli/coding_projects/AIphone/venv/lib/python3.11/site-packages/vocode/turn_based/turn_based_conversation.py", line 24, in __init__
    self.maybe_play_initial_message()
  File "/Users/matteoticli/coding_projects/AIphone/venv/lib/python3.11/site-packages/vocode/turn_based/turn_based_conversation.py", line 28, in maybe_play_initial_message
    self.output_device.send_audio(self.synthesizer.synthesize(self.agent.initial_message))
                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/matteoticli/coding_projects/AIphone/venv/lib/python3.11/site-packages/vocode/turn_based/synthesizer/eleven_labs_synthesizer.py", line 50, in synthesize
    return AudioSegment.from_mp3(io.BytesIO(audio))  # type: ignore
                                 ^^^^^^^^^^^^^^^^^
TypeError: a bytes-like object is required, not 'generator'

How can I resolve this?

LLM

None

Transcription Services

None

Synthesis Services

None

Telephony Services

None

Conversation Type and Platform

No response

Steps to Reproduce

.

Expected Behavior

.

Screenshots

No response

@matteo-ticli matteo-ticli added the bug Something isn't working label Jan 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant