Using the Generative Artificial Intelligence, talking with ChatGPT

From MiRTA PBX documentation
Jump to navigation Jump to search

To be able to talk with ChatGPT, you need three service subscriptions:

- A Google Speech to Text subscription using a Service Account

- A ChatGPT API Key with at least some credit

- A Google Text to Speech subscription using a API Key

For Google Speech to Text, you need to log into the Google console at https://console.cloud.google.com/ and create/select a Project.

In the APIs & Services page, enable the [ Cloud Speech-to-Text API ].

You need to create a Service Account. You can go back in the IAM & Admin page and select [ Service Accounts ] or using the [ Credentials ] section, create a Service Account. Be aware the service account authentication is a JSON file that the web page download automatically and once downloaded, it cannot be downloaded, so you need to carefully save it.

This is the page you are looking for when creating the service account.

For Google Text to Speech, you need to log into the Google console at https://console.cloud.google.com/ and create/select a Project.

In the APIs & Services page, enable the [ Cloud Speech-to-Text API ].

You need to create an API key. Access the Credentials for the [ APIs & Services ] and create an API key. You can restrict the IP allowed to use the service. An API key is something like AIzaSyAVA4f5Q53sxdeAFVESiL1AHdrBXt_q8gc

For ChatGPT API Key, you need to log into the ChatGPT platform at https://platform.openai.com/

Press the [ Start building ] button on the top right and create an Organization. Continue until you can generate the key and buy some credit.

You can review your credit from the project setting page at https://platform.openai.com/settings/organization/general by choosing Usage

AGI or AEAP

You can use the chatGPT integration in both ways, but the AEAP is the best way. AGI will soon be removed. To be able to use the AEAP you need to be sure to have asterisk configured to support this protocol. I am unsure about the oldest asterisk version using it, but it will be advisable to use latest Asterisk 20.x. To configure AEAP in asterisk, you need to create a /etc/asterisk/aeap.conf with the following content:

[my-speech-to-text]
type=client
codecs=!all,ulaw
url=ws://127.0.0.1:9099
protocol=speech_to_text

This will allow direct and very fast speech to text translation using Google Speech services

Functions

Functions are available using gpt-4-turbo and allow the AI to identify your request, ask the parameter and trigger the execution of the destinations. The parameter identified will be available as USR-parametername