Giter Club home page Giter Club logo

fixie-sdk-python's Introduction

fixie-sdk-python

Fixie SDK for Python

Quickstart

pip install fixie

Hello Agent

To start a voice session with a Fixie agent, create a VoiceSession object and call session.start().

from fixie_sdk.voice import audio_local
from fixie_sdk.voice import types
from fixie_sdk.voice.session import VoiceSession
from fixie_sdk.voice.session import VoiceSessionParams


async def main():
    source = audio_local.LocalAudioSource()
    sink = audio_local.LocalAudioSink()
    params = VoiceSessionParams(agent_id=<your agent uuid>)
    client = VoiceSession(source, sink, params)
    await client.warmup()
    await client.start()
    await asyncio.Event().wait()


asyncio.run(main())

Hello Santa

For a more complete example, see the command-line client included with the Fixie SDK: https://github.com/fixie-ai/fixie-sdk-python/blob/main/fixie_sdk/examples/voice_example.py

Installing & Running from Source

  1. Install
poetry install
  1. Run included voice example
poetry run python examples/voice_example.py

Use Ctrl-C to terminate the program.

The example program will use the default microphone and output device (i.e. speaker) for your computer. These are set in this code:

# Get the default microphone and audio output device.
source = audio_local.LocalAudioSource()
sink = audio_local.LocalAudioSink()

You can find more information in the file voice/audio_local.py.

  1. Run included Twilio stream example
poetry run python examples/twilio_stream_example.py
ngrok http 5000

where ngrok output looks like

Forwarding  https://eb06-98-203-158-121.ngrok-free.app -> http://localhost:5000

Following https://www.twilio.com/docs/voice/tutorials/consume-real-time-media-stream-using-websockets-python-and-flask#start-streaming-audio to configure TwiML Bin

<Response>
    <Connect>
        <Stream url="wss://eb06-98-203-158-121.ngrok-free.app/media" />
     </Connect>
</Response>

Call the Twilio number associated with the above TwiML Bin.

Using Your Own Agent

You can pass in the --agent (or -a) input parameter followed by a space and then the ID of your agent.

Using a Different Voice

Adding more voices is a WIP. For now you can use the default voice or can pick any of the voices that are defined here. Pass in the desired voiceID with the --tts-voice (-V) parameter.

Using Your Own Audio Devices

Typically you will want to supply your own audio source and sink (e.g., to pipe the data to the phone network rather than the local audio devices). To do this, simply create your own classes derived from AudioSource and AudioSink and pass them in to the VoiceSession constructor.

fixie-sdk-python's People

Contributors

benlower avatar jerrychocoy avatar juberti avatar mdepinet avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

hp48duck

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.