Skip to content
View in the app

A better way to browse. Learn more.

The AVSIM Community

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

AAO 4.10: having a chat with ChatGPT

Featured Replies

  • Commercial Member

Hello all,

when developing the new AI based features of AAO 4.10, I've implemented a fun series of scripts that allow me to have a conversation with ChatGPT. I will just leave those here, as they also demonstrate some programming techniques that can be useful in AAO.

This example is quite involved as it uses several services at the same time - the ChatGPT API and Microsoft Azure Cognitive Services

- You will have to create your own ChatGPT API account as described in the AAO manual. Be mindful that using ChatGPT is not free, you will be charged for accessing the AI.
- And you will have to create a billable Azure Account, also as pointed at in the AAO manual. While this account is generally free as long as your usage stays below certain thresholds, it still requires a valid means of payment.

Now for the actual code. All my scripts are in a group called "ChatGpt". Remember that you have to stick to my script group and script names so the scripts can call each other. I will provide a link to download the scripts package at the end.

1. "InitRecognition" : this script I have bound to a button. I call it once to initialize the conversation - I am telling ChatGPT how I expect it to behave and what language it should use - and to say hello to me

(STRARR:gptconv)·clear·
'system:you·are·a·friendly·British·assistant.·please·chat·with·me'·(STRARR:gptconv)·push·
'user:Please·say·hello'·(STRARR:gptconv)·push·
1·(>K:ChatGpt-WaitForAnswer)

2. "WaitForAnswer" This is a multi-line RPN script (meaning that you must actually type the two characters "\n", this is not just a line feed!) that sends my request to ChatGPT and waits for the API to answer. Once the answer is in, it will make Azure speak the text that came from ChatGPT

'user:'·(L:AaoVoiceRecPhrase,·String)·scat·(STRARR:gptconv)·push·\n
''·(>L:gptresult,·String)·\n
1·(>K:ChatGpt-SubmitConversation)·\n
:repeat·\n
(L:gptresult,·String)·''·scmp·if{·(GOTO:repeat)·}·\n
'assistant:'·(L:gptresult,·String)·scat·(STRARR:gptconv)·push·\n
(VOICE:Azure|en-GB-LibbyNeural)·(L:gptresult,·String)·(SPEAK:%s1)·\n

3. "SubmitConversation" This script makes the actual call to ChatGPT. The chat will be continued, ChatGPT will always receive the entire data up to this point and answer accordingly. This uses the JScript implementation in AAO

(WSH:jscript|AaoEntry)

function AaoEntry(){
  var len = (STRARR:gptconv).count;
  for (var i = 0; i < len; i++){
   var msgcmd = "(CHATGPTADDMESSAGE:" + (STRARR:gptconv).get(i) + ")";
   AaoCmd.exec(msgcmd);
  }
  AaoCmd.exec("(CHATGPTGETRESULT:gpt-3.5-turbo|gptresult)");
}

4. "StartRecognition": this is the PushToTalk script that starts the Azure voice recognizer. This I have assigned to the Key Down of my joystick button (the next script, "EndRecognition" is assigned to the Key Up, making the button a PTT)

''·(>L:AaoVoiceRecPhrase,·String)·
(DICTATION_START:Azure|en-GB)·

5. "EndRecognition": this is the final element, it stops the voice recognition and starts the cycle for submitting your text and waiting for the answer.

(DICTATION_END)·1·(>K:ChatGpt-WaitForAnswer)


To start a new conversation, call "InitRecognition" again.

https://www.dropbox.com/scl/fi/c55144l9nkhd6mjbt8ju5/ChatGPTScripts.xml?rlkey=rl7i10fit2iatdznej534ys0h&dl=0

Edited by Lorby_SI

LORBY-SI

  • Author
  • Commercial Member

Disclaimer:

Yes, I know that this is probably only relevant for a handful of people who happen to have the API keys already or are willing to go through the trouble of getting them - and paying for the ChatGPT service. I am just showing off here.

Still, I have to say that the Azure Speech API is very good, and definitely worth getting. As long as your text-to-speech and/or speech-to-text requests remain under a certain limit, the usage is free. And both services are VERY good (compared to the standard Windows implementation).

Personally, I think that services like ChatGPT will be free for the end user at some point. Maybe the AI will include some product placement in its answers, but I am pretty sure that there will be a lot more AI services available in the coming years, and that eventually the every day information/chat requests will be free for end users (the usual commercial greed nonwithstanding). 

Edited by Lorby_SI

LORBY-SI

  • Author
  • Commercial Member

And while we're at it, here is another fun implementation of the ChatGPT / Azure combo: a METAR reader:

(NOAA_METAR_ICAO:EDDM)·\n
(CHATGPTADDMESSAGE:system:you·are·the·person·reading·the·airport·information·ATIS·at·munich·airport.)·\n
'user:please·read·the·following·METAR·string·to·me·as·a·weather·report:'·(L:NoaaMetar,·String)·scat·(CHATGPTADDMESSAGE:%s1)·\n
''·(>L:gptresult,·String)·\n
(CHATGPTGETRESULT:gpt-3.5-turbo|gptresult)·\n
:repeat·\n
(L:gptresult,·String)·''·scmp·if{·(GOTO:repeat)·}·\n
(VOICE:Azure|en-GB-LibbyNeural)·(L:gptresult,·String)·(SPEAK:%s1)·\n

 

Edited by Lorby_SI

LORBY-SI

  • Author
  • Commercial Member

..and this one...

''·(>L:purserspeak,·String)·\n
(CHATGPTADDMESSAGE:system:you·are·Molly,·the·purser·on·the·lufthansa·flight·DLH2345·from·munich·to·rome.·in·Rome·it·is·raining·and·the·temperature·is·5·degrees·celsius.·The·flight·is·departing·at·20:00)·\n
(CHATGPTADDMESSAGE:user:please·welcome·the·passengers·on·board·and·read·the·cabin·announcement.·Use·less·than·100·words.)·\n
(CHATGPTGETRESULT:gpt-3.5-turbo|purserspeak)·\n
:waitcomplete·\n
(L:purserspeak,·String)·slen·0·==·if{·(GOTO:waitcomplete)·}·\n
(VOICE:Azure|en-NZ-MollyNeural)·(VOICEEFFECTS:4,100)·(L:purserspeak,·String)·(SPEAK:%s1)·\n


 

LORBY-SI

  • 4 weeks later...
On 1/28/2024 at 4:08 AM, Lorby_SI said:

Still, I have to say that the Azure Speech API is very good, and definitely worth getting.

I've just signed up for it, but struggling to work out where the API key goes...

2 minutes ago, Lorby_SI said:

Menu "Extras->Manage advanced TextToSpeech API Keys"

I don't have that menu option.

1 minute ago, Lorby_SI said:

Then you don't have the current AAO version 4.10

can I update from the app or do I need to download the latest?

 

Archived

This topic is now archived and is closed to further replies.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.