adds eleven labs streaming support
This commit is contained in:
parent
a9424ffaeb
commit
19461eaba4
5 changed files with 99 additions and 20 deletions
|
|
@ -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())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue