AI Chat and ai-ask are self-voicing ChatGPT clients for the BTSpeak from Blazie Technologies.
This post contains audio demonstrations of the main AI Chat app and its little brother ai-ask; information on generating, funding and installing an OpenAI key (which is required to use AI Chat); as well as other information about AI chat and ChatGPT in general.
This page has been updated to reflect the enhancements and updates to AI Chat and ai-ask found in the BTSpeak July and October updates.
In summary, AI Chat is now more consistent and reliable in accessing the latest models and up-to-date data, and the facility for installing your Open AI Key has been enhanced. All errors are logged so you can check them if you encounter issues. If a problematic key file had previously been installed, and AI Chat was giving error messages, running the latest version of AI Chat may repair the problem.
Several Additional AI Chat commands have been implemented and are documented in the help file.
The help files have been fully re-written and can also be read on this page. This will assist you in accessing the Open AI links required to obtain and fund your key.
The following information is from the OpenAI-key help file. Ig you have your key installed, you can skip to the next heading for other info about AI Chat.
OpenAI Key Help
To get started, you’ll need to visit the OpenAI website: register, generate your own OpenAI key, and then fund it with at least $5, in order to use apps like AI Chat to access ChatGPT.
Note that in May 2024 OpenAI has made some changes to this process to give businesses more flexibility around keys. They have also stopped offering free credits for newly-generated OpenAI keys, and expired any existing free credit on existing keys. Rest assured that you can still generate and use a key for personal use, but it must now be funded.
If you previously had a working unfunded key, it will no longer have any credit, so you should skip to item 3 below to fund it.
1: Go to
https://platform.openai.com/signup
and create a free OpenAI account. You should end up on a web page something like “Welcome to the OpenAI developer platform.”
2: Now go to
https://platform.openai.com/api-keys
where you will be asked to verify your mobile number and then are able to generate your key.
Your key starts with sk- and is only displayed once after you generate it, for security reasons. Be sure to copy the key to your clipboard and into a file for safekeeping. Note: your OpenAI Key is essentially like a password. You should handle it with care and not leave it where it could be accessed by others.
3: Finally, you need to fund your key with a minimum of $5. For more information on funding your OpenAI key, visit the OpenAI Pricing Page at:
https://platform.openai.com/account/billing/overview
This is extremely affordable, and you only pay for what you use; no monthly subscription fees. You can fund your key with five or ten dollars, and when the balance drops below a specified level, you will be billed a top-up amount.
A funded key allows you access to the latest GPT models, including GPT-4o and gpt-4-turbo-2024-04-09.
Getting your key onto the BTSpeak
Method 1 (recommended):
Paste the key text into a new text file called openAI_key. The most important thing is that the word “key” is in the file name.
Either, A: Place this key file on an sd card or usb drive, or B: copy it to your BTSpeak Public folder.
When you next run AI Chat, it will search for the key file and, if found, and in the correct key format, move it from your external media or Public directory, to the correct location in your home directory for full app operation.
Method 2:
If the key cannot be found automatically, manually copy the key file into your home directory at /home/pi using the file manager or other means. Ensure the word key is somewhere in the filename.
When you next run AI Chat, it will search for the key file and, if found, and in the correct format, it will move/rename it to the correct location in your home directory for app operation.
Note: Once installed, the key is found at
/home/pi/.openAI_key
Because the key file name starts with a . dot, you will need to show hidden files in the file browser with the letter h, in order to see the key.
Trouble-shooting notes:
If a problematic key file had previously been installed, and AI Chat was giving error messages, running the latest version of AI Chat may repair the problem.
It is strongly recommended that the key file only contain one line containing the key; though the app does attempt to extract a valid key from any line of the file. The Key starts with sk- and is either 51 or 56 characters in length.
You can check the i-chat error log if you have problems with installing your Open AI key.
AI Chat also creates an error log file which includes any significant errors generated while using the app. Checking this log can help diagnose issues with Open AI key registration.
The log is found in the advanced system administration menu.
AI Chat Help
AI Chat is a ChatGPT client for the BTSpeak. Whenever this help file mentions AI Chat, it is referring to the BTSpeak app you are using. When it mentions ChatGPT, it is specifically referring to OpenAI’s artificial intelligence service, based in the cloud.
AI Chat is found in the Applications > Web menu.
You can also add it to your User menu for quick access by pressing control c (dots 1-3-7-8) when on the AI Chat menu item.
To use AI Chat, you first need to generate an OpenAI key and then fund it with at least $5. OpenAI no longer provides a free tier of access for keys. This key is essential for accessing ChatGPT.
For details on obtaining and installing your key on BTSpeak, see the OpenAI Key help topic or you can read it online at
timnoonan.com.au/ai-chat
If you place your OpenAI key in a text file on external media or in the Public directory, with the word “key” anywhere in its file name, when you run AI Chat, it will look for this file and automatically move the key to the correct location in your home directory. If not found in those locations it also searches your home directory tree.
AI Chat is a self-voicing app. This means that after you send ChatGPT your question, it will automatically read out the answer to you. You can stop speech at any time by pressing Dots 7 and 8 together.
AI Chat was originally designed for DECtalk and supports a variety of unique DECtalk features when reading information. For example, italics are spoken in a slightly higher pitch, bold is slightly louder than regular text, and headings are spoken in a higher pitch. Specific information is spelled out, and programming code is read with a higher punctuation level. If you are using DECtalk when you run AI Chat, it will auto-detect DECtalk and utilize the DECtalk enhancements. However, if you prefer to use a different TTS engine, AI Chat adapts and still announces headings, quotes, bullet points, and more.
For new users, AI Chat welcomes you and provides information on key commands. After five uses, the welcome message is trimmed.
When you hear the message “Enter prompt:”, you can Braille or type your question for ChatGPT (termed a prompt) and press Enter.
After a short delay, the response will be spoken in full. If you don’t wish to hear the entire response, press Dots 7 and 8 together to stop speech.
AI Chat operates a little differently than most other BTSpeak apps. This is because it is built around a mainstream ChatGPT script for Linux, and because it is designed to fully self-voice its output.
Essentially, you either type your question and press Enter or type a specific command and press Enter. You can use H-chord for help, but Z-chord does not exit the app at this time.
Note: If you access your BTSpeak using SSH from another computer, you can run AI Chat, type your questions, and the responses will be spoken by the BTSpeak, as well as being sent to your computer screen. You can choose to have tty/screen output or self voicing speech enabled or disabled.
ChatGPT is made aware of the current date and your BTSpeak locale, so it knows the country and language conventions of where you are based. It also knows you are using a BTSpeak running Linux, and that it is using synthetic speech to communicate with you. It knows if your speech is set to DECtalk. This means you can instruct it (with varying results) to use DECtalk commands to control its spoken output.
ChatGPT has no access to any personal information about you, but you can inform it of your name or nickname if you want it to address you directly. Instructions for setting this are provided below.
You can also let it know your interests and preferences for how you prefer information to be presented to you. You can update your name and interests at any time.
While in the current AI Chat session, your most recent questions and answers are made available to ChatGPT, making it easy to get clarification or refine your query. The more context ChatGPT has, the more accurate and relevant its responses will be. It is not very good at guessing, but specific questions usually get specific and more relevant answers. However, if you quit the app and restart it, be aware that ChatGPT does not have access to any of your prior conversations.
By default, AI Chat keeps a running history file containing your questions and answers, adding to this file each time you use the app. If you do not wish your queries and responses to be written to the history file, this setting can be disabled or re-enabled. (See commands below.)
Here are the current AI Chat commands and how to use them (case doesn’t matter):
The first time you run AI Chat, it defaults to gpt-4o, AI Chat’s flagship model.
gpt-4o is the latest model with much faster response times, increased reasoning ability, and is less expensive overall. It seems to have a tendency to make up facts if it isn’t sure. Its knowledge is either current to April 2024, or possibly October 2023.
The other model you can change to is gpt-4-turbo-2024-04-9 which has broad general knowledge current to December 2023. While this gpt-4-turbo model is slower to respond, its world knowledge and web-based information appears to be much more complete. Its general knowledge answers do appear to be more likely to be accurate, with less made up responses.
You can use the FlipModel command to flip the current model from one to the other, which updates the default in your config file. This should update your model responses immediately, though sometimes you may need to restart AI Chat for them to come into effect.
Please note: Although we always request the highest available model for your key, OpenAI sometimes directs the request to a lower model, depending on server load. gpt-4-turbo seems to have more reliable availability than gpt-4o, but this may change.
The most reliable way to get a sense of whether you are on an up-to-date model is to ask ChatGPT a factual question about a recent event in 2023, which was not predicted or known ahead of time. For example, “Who won the Nobel Peace Price in 2023?” The correct answer is: “Narges Mohammadi, an Iranian human rights activist.” The winner was announced on 6 October 2023, so it will work against either model. If it seems like the model only covers up to 2021, you can try using the FlipModel command and ask again, or restart AI Chat.
The history.txt file is stored in the following location:
/home/pi/BTSpeak/ai-chat/history.txt
To find and open the history.txt file with the file browser:
* From your home directory, navigate to BTSpeak and press Enter to enter that directory.
* Then navigate to ai-chat and press Enter to enter the directory.
* Lastly, navigate to history.txt and press Enter to open the file in the editor.
AI Chat also creates an error log file which includes any significant errors generated while using the app. Checking this log can help diagnose issues with Open AI key registration.
The log is found in the advanced system administration menu.
AI Chat uses a configuration file to store various user settings. With the history, name, and IAm commands listed above, and automatic model selection, most users should have little need to access the config file.
The config file allows you to adjust speech settings if you use DECtalk, as well as tailor the model, prompts, and information provided to ChatGPT when you use AI Chat. The config file contains numerous comments to explain its options.
The config file is located at:
/home/pi/.config/ai-chat/ai-chat.conf
Note: You will need to enable hidden files in the file browser by pressing ‘h’ to find and enter the .config directory.
The Open AI Key file is found in the home directory
/home/pi
the file is named
.openAI_key
It is a hidden file, so you will need to press h from the file browser to find it.
For more information about AI Chat and to hear a detailed audio demo, please visit
timnoonan.com.au/ai-chat
ai-ask is a command-line utility meant for single-question Chat GPT enquiries. ai-ask exits after the answer is provided.
Use ai-chat for more detailed questions and follow-on queries.
Important note: the ai-ask utility relies on the AI Chat script and you need to have a funded Open AI key installed to use ai-ask.
ai-ask can be directly accessed from within the BTSpeak editor. Its output is either inserted into the current file below your question, or your question and answer can be written to a new file. It uses the BTSpeak editor Run Host Command feature.
There are a few ways you can use ai-ask from the editor:
On a blank line in the editor, type the following:
After a short pause, the first paragraph of your answer will be spoken, and the entire answer written to the current file, right below your question.
Note: the custom ai-ask instructions encourage Chat GPT to answer your question in a single paragraph, but sometimes additional paragraphs will be provided in the answer. The entire answer is written to the file.
If you would rather your question and answer be written to a new file you can do the following from within the editor:
On a blank line in the editor, type the following:
After a short pause, you should hear the message “New file is open” and be placed at the top of the new file. The first line contains a copy of your command/question, and below that will be the answer to your question.
Note: this is a temporary file. You can close it without saving or save it and provide a file name.
Each time you start the line with the greater-than symbol, the ai-ask question and answer are written to a new file.
To access ai-ask without reference to any text in your document, you can do the following and your answer will be written to a new temporary file.
the text of your command and the full answer will be inserted into a new temporary file.
You can copy all or part of the answer to a different file or save the file to disk.
Note: ai-ask requires the question to be provided as part of the command-line when you run the app; therefore, it is not usable from the BTSpeak User Menu.
Example: ai-ask what is the rename command called in Linux?
Note: if using ai-ask in the shell, Avoid apostrophes in your question as the shell tries to interpret these specially.
Alternate usage for shell use: to avoid the apostrophe problem, enclose your question in double-quotes.
Example: ai-ask “what does Chat GPT’s name stand for?”
Note: this quoting issue does not apply at all If running ai-ask in the editor,
If called from the shell, Only the first paragraph of an ai-ask response is spoken, but the entire answer is displayed to the screen.
AI Chat is built around the open source chatGPT-shell-cli bash script, developed by 0xacx
“A simple, lightweight shell script to use OpenAI’s chatGPT and DALL-E from the terminal without installing python or node.js. The script uses the official ChatGPT model AI Chat-3.5-turbo with the OpenAI API endpoint” Original chatGPT-shell-cli bash script Original chatGPT-shell-cli Readme file
My sincere thanks to 0xacx; without his extensive efforts in developing the original bash script – which handles most of the ChatGPT interaction code – , this enhanced self-voicing BTSpeak app would not have been possible.
Please note that I have endeavoured to keep all the original functionality of the chatGPT-shell-cli script available. It provides a variety of command-line options for specific functionality and non-interactive modes. Only some of these are self-voicing.
however, I have also put in a great deal of work to make AI Chat more intuitive and straight-forward to use, much easier to configure and with the goal to support less technical users who want to benefit from Chat GPT.
Some more advanced features available in the original script do not currently self voice, but in these instances, review mode is always available.
In addition to self-voicing ChatGPT output,,the additions and enhancements I’ve made to 0xacx’s original Chat GPT script include:
I developed AI Chat because I was really excited when I heard about the BTSpeak with accurate braille input and running on Linux. Even before I placed my BTSpeak order, I started researching Chat GPT options for the Linux shell and read about chatgptshell-cli. The first thing I did when my unit arrived was to install my key and try out the in-built Chat GPT app. Sadly, it wasn’t operational, so I downloaded chatgpt-shell-cli and started enhancing it to suit my needs and interests. What started out as a few tweaks, soon let to the original 460 lines of bash code increasing to around 1700 lines (including liberal comments).
That process, combined with my frustration with OpenAI’s Chat GPT Plus’s web interface, got me really thinking about the kinds of features I’d like in a Chat GPT app, which is always at my fingertips. and so AI Chat was born.
40 years ago I taught myself Unix (the father of Linux), regular expressions and fell in love with the power and flexibility of the shell for directing and reformatting information. Unix, at its heart, just seemed purpose-designed for accessibility and transforming information into more accessible formats.
Then, In the very early 90s, my then partner Shane Alderton and I ran Internet Online, a community-based internet access service, as part of the Australian Public Access Network Association (APANA) based on Linux. Many of our users were blind and accessing international email and swaths of online information via the service. Most of my system admin, configuration and use of the Linux system was via my trusty Braille ‘n Speak and its terminal mode.
So, 30 years on, Linux is actually inside a device even smaller than the original Braille ‘n Speak, and I am using the same kinds of tools I used – way back then – developing ways to efficiently and effectively access information..
In the late 90s, when I worked for Royal Blind Society, I developed and ran Today’s News Now – a fully automated telephone service in New South Wales Australia providing access to the major daily newspapers and our talking book catalogue. This was somewhat like the News Line for the Blind service. It was built round DECtalk, and used rich Perl regular expression rules to reformat content to a spoken form, and to correct the endless DECtalk pronunciation problems. I became very familiar with its strengths – and all its foibles.
So, it was the fortuitous unfolding of all these factors, aligned with my background in voice user interface design, that led me on this journey to start exploring just what might be possible with this fledgling pocket-sized contemporary take on the venerable Braille ‘n Speak.
This is only the first AI Chat release ; I have a lot of ideas to explore and features I think would be of value. It’s taken a lot of work to get AI Chat to this point, but now the code is in good shape for creative experiments and expansions down the track.
Please let me know how you find AI Chat and what things you might like me to consider for future versions.
Enjoy
Tim Noonan. tim@timnoonan.com.au
Tweetwebsite by twpg
Sorry, comments are closed for this post.