Skip to content

Instantly share code, notes, and snippets.

@sheunaluko
Last active February 22, 2023 02:01
Show Gist options
  • Save sheunaluko/3a2fdf28cac81a2ddd4678397c00f89d to your computer and use it in GitHub Desktop.
Save sheunaluko/3a2fdf28cac81a2ddd4678397c00f89d to your computer and use it in GitHub Desktop.
This is code for enabling voice interaction with the ChatGPT Research Preview. In order to use it (in Chrome or Safari which support the Web Speech API), simply paste the following code into the javascript console of the ChatGPT web application, accept "allow microphone", and then start talking!
/* helper function for loading an external script */
function addScript(src) {
return new Promise((resolve, reject) => {
const s = document.createElement('script');
s.setAttribute('src', src);
s.addEventListener('load', resolve);
s.addEventListener('error', reject);
document.body.appendChild(s);
});
}
/* load the functionality from the tidyscripts library, which I maintain. Feel free to see the source code! */
await addScript("https://tidyscripts.com/tidyscripts_web_umd.js")
/*
Initialize the voice modules.
If you only want the Speech Recognition without TTS, then use tsw.umd.chatgpt.start_speech_recognition_and_link_to_input()
*/
await tsw.umd.chatgpt.initialize_voice_system_with_tts()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment