Asterisk Google Cloud Speech API Integration - Omid-Mohajerani/VICIdial GitHub Wiki
Operating system: Debian 12 Asterisk version: 18
Install the gcloud CLI
source: https://cloud.google.com/sdk/docs/install#deb
sudo apt-get update
sudo apt-get install apt-transport-https ca-certificates gnupg curl sudo git
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo gpg --dearmor -o /usr/share/keyrings/cloud.google.gpg
echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.cloud.google.com/apt cloud-sdk main" | sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list
sudo apt-get update && sudo apt-get install google-cloud-cli
Install Asterisk
cd /usr/src/
wget https://downloads.asterisk.org/pub/telephony/asterisk/asterisk-18-current.tar.gz
tar -xvf asterisk-18-current.tar.gz
ls
cd asterisk-18.21.0/contrib/scripts/ #Change based on your asterisk version folder name
./install_prereq install
cd ../../
./configure
make
make install
make samples
make config
asterisk
Clone and Run aesp-speech-to-text
apt install -y npm git
cd /usr/src/
git clone https://github.com/asterisk/aeap-speech-to-text.git
cd aeap-speech-to-text/
npm install
Enable Google Cloud Speech API
Authorise the Gcloud CLI
gcloud init
set default login
gcloud auth application-default login
Edit aeap.conf
[my-speech-to-text]
type=client
codecs=!all,ulaw
url=ws://127.0.0.1:9099
protocol=speech_to_text
Dialplan
[internal]
exten => 550,1,NoOp()
same => n,Answer()
same => n,SpeechCreate(my-speech-to-text)
same => n,SpeechStart()
same => n,SpeechBackground(hello-world)
same => n,Verbose(0,${SPEECH_TEXT(0)})
same => n,NoOP( --- ${SPEECH_TEXT(0)} ----- )
same => n,SpeechDestroy()
same => n,Hangup()