adds eleven labs streaming support

This commit is contained in:
Ajay Raj 2023-03-28 15:57:53 -07:00
commit 19461eaba4
5 changed files with 99 additions and 20 deletions

View file

@ -5,6 +5,7 @@ from dotenv import load_dotenv
load_dotenv()
import vocode
from vocode.streaming.hosted_streaming_conversation import HostedStreamingConversation
from vocode.streaming.streaming_conversation import StreamingConversation
from vocode.helpers import create_microphone_input_and_speaker_output
@ -23,12 +24,15 @@ from vocode.streaming.models.agent import (
ChatGPTAgentConfig,
)
from vocode.streaming.models.message import BaseMessage
from vocode.streaming.models.synthesizer import AzureSynthesizerConfig
from vocode.streaming.models.synthesizer import (
AzureSynthesizerConfig,
ElevenLabsSynthesizerConfig,
RimeSynthesizerConfig,
)
logging.basicConfig()
logging.root.setLevel(logging.INFO)
if __name__ == "__main__":
microphone_input, speaker_output = create_microphone_input_and_speaker_output(
streaming=True, use_default_devices=False
@ -44,10 +48,12 @@ if __name__ == "__main__":
agent_config=ChatGPTAgentConfig(
initial_message=BaseMessage(text="Hello!"),
prompt_preamble="The AI is having a pleasant conversation about life",
generate_responses=True,
generate_responses=False,
cut_off_response=CutOffResponse(),
),
synthesizer_config=AzureSynthesizerConfig.from_output_device(speaker_output),
synthesizer_config=ElevenLabsSynthesizerConfig.from_output_device(
speaker_output, api_key=vocode.getenv("ELEVEN_LABS_API_KEY")
),
)
signal.signal(signal.SIGINT, lambda _0, _1: conversation.deactivate())
asyncio.run(conversation.start())

View file

@ -3,6 +3,8 @@ import logging
import signal
from dotenv import load_dotenv
from vocode.streaming.synthesizer.eleven_labs_synthesizer import ElevenLabsSynthesizer
load_dotenv()
from vocode.streaming.agent.chat_gpt_agent import ChatGPTAgent
@ -26,6 +28,7 @@ from vocode.streaming.models.agent import (
from vocode.streaming.models.message import BaseMessage
from vocode.streaming.models.synthesizer import (
AzureSynthesizerConfig,
ElevenLabsSynthesizerConfig,
GoogleSynthesizerConfig,
RimeSynthesizerConfig,
)
@ -60,8 +63,10 @@ hella, down, fire, totally, but like, slay, vibing, queen, go off, bet, sus,
cut_off_response=CutOffResponse(),
)
),
synthesizer=AzureSynthesizer(
AzureSynthesizerConfig.from_output_device(speaker_output)
synthesizer=ElevenLabsSynthesizer(
ElevenLabsSynthesizerConfig.from_output_device(
speaker_output, api_key=vocode.getenv("ELEVEN_LABS_API_KEY")
)
),
logger=logger,
)