Package: milocode
Community|Docs|DashboardvocodeBuild voice-based LLM apps in minutesVocode is an open source library that makes it easy to build voice-based LLM apps. Using Vocode, you can build real-time streaming conversations with LLMs and deploy them to phone calls, Zoom meetings, and more. You can also build personal assistants or apps like voice-based chess. Vocode provides easy abstractions and integrations so that everything you need is in a single library.We're actively looking for community maintainers, so please reach out if interested!⭐️ Features🗣Spin up a conversation with your system audio➡️ 📞Set up a phone number that responds with a LLM-based agent📞 ➡️Send out phone calls from your phone number managed by an LLM-based agent🧑‍💻Dial into a Zoom call🤖Use an outbound call to a real phone number in a Langchain agentOut of the box integrations with:Transcription services, including:DeepgramAssemblyAIGoogle CloudWhisper.cppMicrosoft AzureWhisperRevAILLMs, including:ChatGPTGPT-4AnthropicGPT4AllSynthesis services, including:Rime.aiMicrosoft AzureGoogle CloudPlay.htEleven LabsCoquiCoqui (OSS)gTTSStreamElementsBarkCheck out our React SDKhere!🫂 Contribution and RoadmapWe're an open source project and are extremely open to contributors adding new features, integrations, and documentation! Please don't hesitate to reach out and get started building with us.For more information on contributing, see ourContribution Guide.And check out ourRoadmap.We'd love to talk to you onDiscordabout new ideas and contributing!🚀 Quickstart (Self-hosted)pipinstall'vocode'importasyncioimportloggingimportsignalfromvocode.streaming.streaming_conversationimportStreamingConversationfromvocode.helpersimportcreate_streaming_microphone_input_and_speaker_outputfromvocode.streaming.transcriberimport*fromvocode.streaming.agentimport*fromvocode.streaming.synthesizerimport*fromvocode.streaming.models.transcriberimport*fromvocode.streaming.models.agentimport*fromvocode.streaming.models.synthesizerimport*fromvocode.streaming.models.messageimportBaseMessageimportvocode# these can also be set as environment variablesvocode.setenv(OPENAI_API_KEY="<your OpenAI key>",DEEPGRAM_API_KEY="<your Deepgram key>",AZURE_SPEECH_KEY="<your Azure key>",AZURE_SPEECH_REGION="<your Azure region>",)logging.basicConfig()logger=logging.getLogger(__name__)logger.setLevel(logging.DEBUG)asyncdefmain():(microphone_input,speaker_output,)=create_streaming_microphone_input_and_speaker_output(use_default_devices=False,logger=logger,)conversation=StreamingConversation(output_device=speaker_output,transcriber=DeepgramTranscriber(DeepgramTranscriberConfig.from_input_device(microphone_input,endpointing_config=PunctuationEndpointingConfig(),)),agent=ChatGPTAgent(ChatGPTAgentConfig(initial_message=BaseMessage(text="What up"),prompt_preamble="""The AI is having a pleasant conversation about life""",)),synthesizer=AzureSynthesizer(AzureSynthesizerConfig.from_output_device(speaker_output)),logger=logger,)awaitconversation.start()print("Conversation started, press Ctrl+C to end")signal.signal(signal.SIGINT,lambda_0,_1:conversation.terminate())whileconversation.is_active():chunk=awaitmicrophone_input.get_audio()conversation.receive_audio(chunk)if__name__=="__main__":asyncio.run(main())📞 Phone call quickstartsTelephony Server - Self-hostedInbound calls - HostedOutbound calls - Hosted🌱 Documentationdocs.vocode.devRecording audio input (human speech):...
    await conversation.start()

    from vocode.streaming.pubsub.base_pubsub import AudioFileWriterSubscriber

    subscriber = AudioFileWriterSubscriber(
        "AudioFileWriterSubscriber", sampling_rate=44100 # 8000 for Twilio
    )
    from vocode import pubsub

    pubsub.subscribe(subscriber=subscriber, topic="human_audio_streams")
    audio_sub_task = asyncio.create_task(subscriber._run_loop())

    signal.signal(signal.SIGINT, lambda _0, _1: conversation.terminate())
    signal.signal(signal.SIGINT, lambda _0, _1: subscriber.terminate())
    signal.signal(signal.SIGINT, lambda _0, _1: audio_sub_task.cancel())