Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Add automatic reading function? #534

Open
Lufffya opened this issue Mar 1, 2023 · 10 comments
Open

[Feature] Add automatic reading function? #534

Lufffya opened this issue Mar 1, 2023 · 10 comments
Labels
enhancement New feature or request

Comments

@Lufffya
Copy link

Lufffya commented Mar 1, 2023

Feature description

Can you add automatic reading function for chatgpt answers?
As shown in the figure:
image
I hope that after I say hello, there will be a reading button behind the chatgpt answer (Like those three).
Click this button to automatically read the chatgpt answer(Hello! How can I assist you today?)

Motivation

I just think it can be beneficial to learning, because chatgpt originally supports multiple languages.
When I have to ask questions in an unskilled language, reading can help me understand better and will be more interesting.
Thanks!!!

Alternatives

No response

Additional context

No response

@Lufffya Lufffya added the enhancement New feature or request label Mar 1, 2023
@dsernst
Copy link

dsernst commented Mar 4, 2023

Do you mean reading the response out loud, as audio?

@dsernst
Copy link

dsernst commented Mar 4, 2023

I have been playing with this, I was able to get some basic JS working to find the most recent reply and read it aloud using the built in SpeechSynthesizer API.

I added this to my ~/.chatgpt/main.js file:

// Say command: read text aloud
function say(text) {
  speechSynthesis.speak(new SpeechSynthesisUtterance(text))
}

// Find the most recent reply
function lastReply() {
  const replies = document.getElementsByClassName('prose')
  const last = replies[replies.length - 1]
  return last.textContent
}

// Register a sayLast function to the global window so we can call it later.
window.sayLast = () => say(lastReply())

// Register hotkey Cmd+S (Ctrl+S on Windows) to start/stop
document.addEventListener('keydown', function (event) {
  // Ctrl + S or Cmd + S hotkey
  if ((event.ctrlKey || event.metaKey) && event.key === 's') {
    if (speechSynthesis.speaking) {
      speechSynthesis.cancel()
    } else {
      sayLast()
    }

    event.preventDefault() // Prevent the default action of saving the page
  }
})
console.log('sayLast() 🔈 function installed, Cmd + S hotkey to activate')

Then in a conversation, I can press Cmd+S to have the most recent answer read aloud.

Previous: Then in a conversation, I open the Dev Tools (Right click > Inspect Element), switch to the Console tab, and can invoke the sayLast() function to have ChatGPT's most recent reply read aloud.


Possible Improvements

The hotkey works pretty well for me, but some other options:

  1. Add a button next to replies to have them read aloud, as OP originally suggested.
  2. Add a toggleable preference to automatically read all replies aloud. Ideally this would be a little thing visible in the window, so it can be turned on/off easily.

lencx added a commit that referenced this issue Mar 5, 2023
lencx added a commit that referenced this issue Mar 5, 2023
@chuyueye
Copy link

chuyueye commented Mar 6, 2023

Can voice engine pronounce bilingual text?Now I can only select on lingua in the setting

@lencx
Copy link
Owner

lencx commented Mar 6, 2023

Can voice engine pronounce bilingual text?Now I can only select on lingua in the setting

It is a built-in browser API and does not seem to support multilingual synthesis.

@neoOpus
Copy link

neoOpus commented Mar 8, 2023

it would be better also to use Edge TTS

@null15
Copy link

null15 commented Apr 5, 2023

Can I use ElevenLabs for the TTS?

https://api.elevenlabs.io/docs#/voices/Get_voices_v1_voices_get

@LeonChow5929
Copy link

There is "No Data" when I choose Set Speech Language. Dose anyone could tell me way?

@OMGHWORK
Copy link

There is "No Data" when I choose Set Speech Language. Dose anyone could tell me way?

Workaround: open developer tools, execute speechSynthesis.getVoices() in the console and copy the voiceURI to the speech_lang parameter in chat.conf.json

@pablorq
Copy link

pablorq commented May 9, 2023

The workaround doesn't work on Ubuntu 23.04:

> speechSynthesis.getVoices()
> ReferenceError: Can't find variable: speechSynthesis

Any idea?

@Frank15140156026
Copy link

hello

SsomsakTH pushed a commit to SsomsakTH/ChatGPT that referenced this issue Jul 24, 2023
SsomsakTH pushed a commit to SsomsakTH/ChatGPT that referenced this issue Jul 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

10 participants