Coder Social home page Coder Social logo

asterisk-assistant's Introduction

Asterisk Asssistant

Have a voice assistant on Asterisk PBX Server using Google for Speach recognition and for Text-to-Speech. It can integrate with Home Assistant by recognizing the intention of the speaker.

How it works

There are three parts on the recognition (Speech Recognition, Text-to-Speech, Intent) on three seperate files:

Speech Recognition (sr.py)

Records the speaker to a file as a wav and sends it to the recognizer to get the output text. This is stored in a variable called ${recognition}.

Text-to-Speech (tts.py)

Takes as a text argument and uploads it to google to get the audio file which is saved as an mp3. The audio file is then streamed to the listener.

Intent (hass.py)

This finds the closest sentence that matches the sentences provided on the actions variable. It can support multiple sentences for the same event like you can see at the example provided on hass.py file. There are some options that are needed for each action type so that they can communicate succesfully with Home assistant.

Example of extensions.conf

Whith this example when you dial 45 it will direct you to the voiceassistant. This is responsible for calling all the AGI scripts and repeat itself after each successfull recognition. There are 3 ways to stop the excecution:

  • You Hang Up
  • You don't say anything (endvoice is triggered)
  • You say Goodbye which will trigger the end action type
[dialplan]
exten => 45,1,Gosub(voiceassistant,${EXTEN},1)

[voiceassistant]
exten => _X.,1,Answer()
exten => _X.,n,Set(VOLUME(TX)=15)
exten => _X.,n(startvoice),NoOP(Started voice assistant)
exten => _X.,n,agi(sr.py)
exten => _X.,n,GotoIf($["${recognition}" == ""]?endvoice)
exten => _X.,n,agi(hass.py,${recognition})
exten => _X.,n,agi(tts.py,${hass_text})
exten => _X.,n,Goto(startvoice)
exten => _X.,n(endvoice),Hangup()

Install

You might want to edit the init section to meet your needs, like language, hass_url, hass_token and the actions:

sudo apt install ffmpeg
sudo pip install -r requirements.txt
sudo cp sr.py /var/lib/asterisk/agi-bin/
sudo cp tts.py /var/lib/asterisk/agi-bin/
sudo cp hass.py /var/lib/asterisk/agi-bin/
sudo chown asterisk:asterisk /var/lib/asterisk/agi-bin/*.py
sudo chmod +x /var/lib/asterisk/agi-bin/*.py

What does this help me achieve...

  • Use NLP to make conversations
  • Connect with my home assistant to control appliances
  • Keep a text transcript of a conversation.
  • Many more that I haven't thought yet...

Insipration

This is inspired by the asterisk-speech-recog project which seems to be outdated.

Video Preview

IMAGE ALT TEXT HERE

asterisk-assistant's People

Contributors

bkbilly avatar ssa1357 avatar

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.