Sounds interesting

My blog and podcast

Introducing AI Chat, a Self-Voicing ChatGPT App for the BTSpeak

Introduction

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.

Listen to or download an audio demonstration of AI Chat in action:

Download the audio demo

Listen to or Download an audio demonstration of ai-ask, the baby brother of AI Chat, for asking single questions right from within the BTSpeak editor:

Download the audio demo

Obtaining and Funding an OpenAI 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.

Contents of AI Chat Help File

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):

  • To stop speech at any time, including the start-up message, press Dots 7 and 8 together, or press Enter on a blank line.
  • To exit the app, press q and press Enter.
  • To review the raw GPT response, not pre-formatted for speech output, press r and Enter. z-Chord to return to Chat GPT.
  • To read the speech-friendly pre-processed markdown response, press p and Enter. z-Chord to return to Chat GPT.
  • To flip between gpt-4-turbo-2024/04/09 and gpt-4o models, type FlipModel (all one word) and press Enter. The model setting will also be updated in your config file for future sessions.
  • To check which model is active, type ModelStatus (all one word) and press Enter.
  • To let ChatGPT know your first name or nickname, type MyName=Name (all one word, using the equals sign) and press Enter. Your name will be added to the config file, and your name will be supplied to ChatGPT.
  • To tell ChatGPT some details about your interests, or how you prefer information to be presented in its responses, type IAm= and press Enter. The words “I am” and all text to the right of the equals sign are added to the config file and made available to ChatGPT. For example, you might type IAm=interested in assistive technology, Linux, and cooking. Please use tactile and auditory metaphors to assist a non-visual learner.
  • To check what IAm details are in your config file, you can use the IAmStatus command. If there are changes you wish to make to your IAm information, you can issue another IAm= command, and your new details will overwrite the earlier IAm details. You can also edit the config file to fine-tune your IAm information.
  • To get assistance with Linux commands, type the word command followed by the colon character dots 1-4-5, then a space, followed by a description of the action you want to perform, and press enter. E.g. “command: list all files in the current directory, one per line.” Chat GPT will then propose a command for you to review, run or ignore. If DECtalk is set, the proposed command is spelled out with all punctuation for clarity. Reviewing the proposed command allows you to check it in detail. If you don’t understand the command, don’t execute it!
  • To execute a shell command from within AI Chat, start the command with the ! exclamation symbol, immediately followed by your command and press enter. The command will be executed and you will be returned to AI Chat. You can also use !sh to spawn a child shell from within AI chat. type exit to return to the app.
  • To disable writing to the history file, type HistoryOff (all one word) and press Enter.
  • To re-enable writing to the history file, type HistoryOn (all one word) and press Enter.
  • To check the history writing status, type HistoryStatus (all one word) and press Enter.
  • To disable sending output to the tty/screen, type TtyOff. If self voicing speech is disabled,it speech will be re-enabled. This will also disable your questions being sent to the tty, so you will not get any keyboard echo.
  • To enable sending output to the tty/screen, type TtyOn
  • to check the status of writing output to the tty/screen, type TtyStatus
  • To disable self-voicing speech, type SpeechOff. If tty output is disabled, it will be re-enabled.
  • To enable self-voicing speech,, type SpeechOn
  • to check the status of self-voicing speech, type SpeechStatus

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

Contents of the ai-ask help file

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:

1. Inserting the answer into your current file

On a blank line in the editor, type the following:

  • Start the line with a single < less than symbol. In grade 0, this is dots 1-2-6
  • Then type the command ai-ask followed by a space
  • Now type your question, but don’t press enter, as this will move you to a new line.
  • You can check that you are on the line containing your question by pressing c-Chord.
  • Finally, to send your question to ai-ask you can either enter ctrl-t or e-Chord r to run the command.

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.

2. Sending your question and answer to a new 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:

  • Start the line with a single > greater than symbol. In grade 0, this is dots 3-4-5
  • Then type the command ai-ask followed by a space
  • Now type your question, but don’t press enter, as this will move you to a new line.
  • You can check that you are on the line containing your question by pressing c-Chord.
  • Finally, to send your question to ai-ask, you can either enter ctrl-t or e-Chord r to run the command.

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.

3. Typing your question directly into the ctrl-t command prompt.

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.

  • type control-t
  • at the prompt, type ai-ask and a space
  • type your question and then press enter.

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.

ai-ask Usage in the shell: ai-ask your question

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.

Based on an Existing Chat GPT script

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.

List of AI Chat Features and How AI Chat differs from the Original Script?

In addition to self-voicing ChatGPT output,,the additions and enhancements I’ve made to 0xacx’s original Chat GPT script include:

  • Checked for open AI api keys in the /home/pi user’s home directory, compatible with BTSpeak Chat GPT key location guidelines
  • if not found, check if a file containing a key is in the Public folder (and soon searching external media devices). If found it is moved to the correct location.
  • added a user configuration file so the script doesn’t need to be edited by the user.
    • This file is optional, if the user is satisfied with the pre-set defaults.
    • Key=Value pairs to set preferred DECtalk voice name, rate, volume and pitch to be configured as well as a contrast voice name, and off-set pitch volume and rate values for voice font reading of various markdown elements such as headings and emphasis.
    • user can specify a range of values used for GPT interactions including the preferred GPT model, context size, initial Chat GPT prompts and more.
    • If not present, this configuration file is now created by the AI Chat app;
    • Robust configuration file parsing, including ignoring case of keys, removing leading spaces or quoting of key value text. Some valid ranges for key values.
  • a range of in-app commands to adjust the config file contents without nee to edit it externally.
  • added self voicing for key errors like key not found, or key appears to not be in the required format,
  • fine-tuned the wordings of the initial Chat GPT prompts for better BTSpeak aware responses.
  • Provide ChatGPT with the date, user’s locale (location) and optionally name and interests.
  • redoubled efforts to ensure the most capable model is loaded with the most current general knowledge.
  • Created a simple ask-ai mode for asking a single question without using the full AI Chat app.
    • Currently this is accessed using the ai-ask command.
    • so you can enter: ai-ask who is Deane Blazie – and you hear the answer.
    • You can also call this ai-ask command from within Nano (the BTSpeak editor) and it will speak the first paragraph of the answer and then insert the full response into a Nano file, for reading or later editing.
  • wrote a markdown self-voicing renderer (with extra voice-font functionality for users of DECtalk). For all TTS engines it supports voicing the following markdown elements in a clear and concise form.
    • announce link name
    • announce image alt text or title
    • announce bullet points and sub-points;
    • announce markdown to-do and done items,
    • announce headings and their level e.g., “H2: What is ChatGPT?”
    • (DECtalk-only) differentiate block quote, text in single quotes and text in back tick “ quotes from regular text
    • DECtalk voice fonts for emphasis types including Bold, Italics plus Bold and Italics
  • added a ‘bang command’ feature (exclamation mark command) so a user can start the line with the exclamation mark immediately followed by a bash command , and it will be executed in a sub-shell and the results shown on screen. You are automatically returned to AI Chat when the command finishes. For example typing ‘!ls -1’ would list the file names in the current directory, one per line, and return you to AI Chat….
  • also supports ‘!sh’ (exclamation mark s h) to start a bash sub-shell. Type ‘exit’ to return to AI Chat
  • for increased safety, added DECtalk spelling out the command-line generated by the ‘command:’ prefix command. When you prefix your prompt with ‘command:’ and ask a question about how to do something in linux, Chat GPT attempts to return a single command line to do the job. This is spelled out and you are asked if you wish to run the command or not. This is a feature offered in the original script, but I have worked to ensure the command line is spelt out fully for DECtalk users, so you are clear what the proposed command line contains. This is an advanced feature for people with some shell experience!

AI Chat’s Origins and a bit About Me

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

btgpt Beta Resources

Welcome to btgpt beta Page Status: I am in the process of significant changes and rewrites to these instructions in readiness for BTSpeak Beta test group access. Thank you for your interest in testing the btg beta on your BTSpeak! I hope you will find the software functional and enjoyable to use. I invite your… Continue Reading btgpt Beta Resources

Updated for watch OS4 and Series 3 – Tim Noonan’s Apple Watch Accessibility with Voiceover Review

This is a live review; as I gain more experience with the new Watch hardware and watchOS 4 I’ll update the document. Last updated 6 December 2017 to include changes for watchOS 4.2 including real Siri voice support. Previously updated to include some LTE comments, additional notes on touch-screen sensitivity and responsiveness, and a section… Continue Reading Updated for watch OS4 and Series 3 – Tim Noonan’s Apple Watch Accessibility with Voiceover Review

Tick Tock Apple Watch 1S My Hopes and speculations of what is next

One Year In with my Apple Watch Originally written in April 2016. Updated 25 October 2016 following release of new Watch hardware and OS. Last year I wrote and progressively updated an extensive blog post on Apple Watch Accessibility with Voiceover which expands on some of the points I make here. I received my Apple… Continue Reading Tick Tock Apple Watch 1S My Hopes and speculations of what is next

Welcome to Sounds Interesting – my new Blog and Podcast

New Year, New Website, , New Blog. Hi I’m Tim Noonan and I’d like to welcome you to my new Blog and Podcast which I’m calling Sounds Interesting. As a blind person I’ve always had a great interest in sound and in voice, and I’ve been fortunate to be able to combine this interest in… Continue Reading Welcome to Sounds Interesting – my new Blog and Podcast

website by twpg

This website uses a Hackadelic PlugIn, Hackadelic SEO Table Of Contents 1.7.3.