Skip to main content

The all-in-one voice SDK

Project description

  vocode

Build voice-based LLM apps in minutes

Vocode 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.

⭐️ Features

Check out our React SDK here!

🫂 Contribution

We'd love for you all to build on top of our abstractions to enable new and better LLM voice applications!

You can extend our BaseAgent, BaseTranscriber, and BaseSynthesizer abstractions to integrate with new LLM APIs, speech recognition and speech synthesis providers. More detail here.

You can also work with our BaseInputDevice and BaseOutputDevice abstractions to set up voice applications on new surfaces/platforms. More guides for this coming soon!

Because our StreamingConversation runs locally, it's relatively quick to develop on! Feel free to fork and create a PR and we will get it merged as soon as possible. And we'd love to talk to you on Discord!

🚀 Quickstart (Self-hosted)

pip install 'vocode[io]'
import asyncio
import signal

import vocode
from vocode.streaming.streaming_conversation import StreamingConversation
from vocode.helpers import create_microphone_input_and_speaker_output
from vocode.streaming.models.transcriber import (
    DeepgramTranscriberConfig,
    PunctuationEndpointingConfig,
)
from vocode.streaming.agent.chat_gpt_agent import ChatGPTAgent
from vocode.streaming.models.agent import ChatGPTAgentConfig
from vocode.streaming.models.message import BaseMessage
from vocode.streaming.models.synthesizer import AzureSynthesizerConfig
from vocode.streaming.synthesizer.azure_synthesizer import AzureSynthesizer
from vocode.streaming.transcriber.deepgram_transcriber import DeepgramTranscriber

# these can also be set as environment variables
vocode.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>",
)


async def main():
    microphone_input, speaker_output = create_microphone_input_and_speaker_output(
        streaming=True, use_default_devices=False
    )

    conversation = StreamingConversation(
        output_device=speaker_output,
        transcriber=DeepgramTranscriber(
            DeepgramTranscriberConfig.from_input_device(
                microphone_input, endpointing_config=PunctuationEndpointingConfig()
            )
        ),
        agent=ChatGPTAgent(
            ChatGPTAgentConfig(
                initial_message=BaseMessage(text="Hello!"),
                prompt_preamble="Have a pleasant conversation about life",
            ),
        ),
        synthesizer=AzureSynthesizer(
            AzureSynthesizerConfig.from_output_device(speaker_output)
        ),
    )
    await conversation.start()
    print("Conversation started, press Ctrl+C to end")
    signal.signal(signal.SIGINT, lambda _0, _1: conversation.terminate())
    while conversation.is_active():
        chunk = microphone_input.get_audio()
        if chunk:
            conversation.receive_audio(chunk)
        await asyncio.sleep(0)


if __name__ == "__main__":
    asyncio.run(main())

☁️ Quickstart (Hosted)

First, get a free API key from our dashboard.

pip install 'vocode[io]'
import asyncio
import signal

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
from vocode.streaming.models.transcriber import (
    DeepgramTranscriberConfig,
    PunctuationEndpointingConfig,
)
from vocode.streaming.models.agent import ChatGPTAgentConfig
from vocode.streaming.models.message import BaseMessage
from vocode.streaming.models.synthesizer import AzureSynthesizerConfig

vocode.api_key = "<your API key>"


if __name__ == "__main__":
    microphone_input, speaker_output = create_microphone_input_and_speaker_output(
        streaming=True, use_default_devices=False
    )

    conversation = HostedStreamingConversation(
        input_device=microphone_input,
        output_device=speaker_output,
        transcriber_config=DeepgramTranscriberConfig.from_input_device(
            microphone_input,
            endpointing_config=PunctuationEndpointingConfig(),
        ),
        agent_config=ChatGPTAgentConfig(
            initial_message=BaseMessage(text="Hello!"),
            prompt_preamble="Have a pleasant conversation about life",
        ),
        synthesizer_config=AzureSynthesizerConfig.from_output_device(speaker_output),
    )
    signal.signal(signal.SIGINT, lambda _0, _1: conversation.deactivate())
    asyncio.run(conversation.start())

📞 Phone call quickstarts

🌱 Documentation

docs.vocode.dev

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

vocode-0.1.98.tar.gz (4.6 MB view details)

Uploaded Source

Built Distribution

vocode-0.1.98-py3-none-any.whl (4.7 MB view details)

Uploaded Python 3

File details

Details for the file vocode-0.1.98.tar.gz.

File metadata

  • Download URL: vocode-0.1.98.tar.gz
  • Upload date:
  • Size: 4.6 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.2 CPython/3.10.10 Darwin/21.6.0

File hashes

Hashes for vocode-0.1.98.tar.gz
Algorithm Hash digest
SHA256 50b626621d788dce7054a88d6f7be3209bf99910e58eaa5016fb192c80c4d31b
MD5 1161af879c8b380a10135299c020a3a3
BLAKE2b-256 9b684e26c8902b37e36c68a46d8b570691b84e7d37f260fb090e9ca714c682b2

See more details on using hashes here.

File details

Details for the file vocode-0.1.98-py3-none-any.whl.

File metadata

  • Download URL: vocode-0.1.98-py3-none-any.whl
  • Upload date:
  • Size: 4.7 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.2 CPython/3.10.10 Darwin/21.6.0

File hashes

Hashes for vocode-0.1.98-py3-none-any.whl
Algorithm Hash digest
SHA256 a0180eea5207fe2abb2c0e56087c38b8263deb506bf38bd71c12820474ec01e4
MD5 a972bcf46c4c59a9b7dcf0cfc5baf9be
BLAKE2b-256 9f243bcd902831d6a2eb0405b6a062fbf40114068c272482d362e4e297bb01aa

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page