C-Nedelcu / talk-to-chatgpt

Talk to ChatGPT AI using your voice and listen to its answers through a voice
GNU Affero General Public License v3.0
1.97k stars 331 forks source link

Option for Amazon Polly #28

Closed Ty-lerCox closed 1 year ago

Ty-lerCox commented 1 year ago

I have pulled down the project and attempted to add this myself, but Amazon's Polly API generates very pleasant speech-to-text.

I wish there were an option or adding an AWS API key and selecting an Amazon Polly's voice.

Ty-lerCox commented 1 year ago

This almost works. The tracks overlap with one another.


function CN_SayOutLoud(text) {
    console.log(text);
    if (!text || CN_SPEAKING_DISABLED) {
        if (CN_SPEECH_REC_SUPPORTED && CN_SPEECHREC && !CN_IS_LISTENING && !CN_PAUSED && !CN_SPEECHREC_DISABLED) CN_SPEECHREC.start();
        clearTimeout(CN_TIMEOUT_KEEP_SPEECHREC_WORKING);
        CN_TIMEOUT_KEEP_SPEECHREC_WORKING = setTimeout(CN_KeepSpeechRecWorking, 100);
        return;
    }

    // Are we speaking?
    if (CN_SPEECHREC) {
        clearTimeout(CN_TIMEOUT_KEEP_SPEECHREC_WORKING);
        CN_SPEECHREC.stop();
    }

    // Let's speak out loud
    console.log("Saying out loud: " + text);

    AWS.config.update({
        accessKeyId: "",
        secretAccessKey: "",
        region: "us-east-1"
    });

    var polly = new AWS.Polly();

    var params = {
        OutputFormat: "mp3",
        Text: text,
        VoiceId: "Joanna"
    };

    polly.synthesizeSpeech(params, function(err, data) {
    if (err) {
        console.log(err, err.stack);
    } else {
        var uInt8Array = new Uint8Array(data.AudioStream);
        var arrayBuffer = uInt8Array.buffer;
        var blob = new Blob([arrayBuffer]);
        var audioElement = new Audio();
        audioElement.src = URL.createObjectURL(blob);
        audioElement.play();
    }
    });
}```
Ty-lerCox commented 1 year ago

https://github.com/Ty-lerCox/talk-to-chatgpt

Here is a hacky implementation of it.

C-Nedelcu commented 1 year ago

Would you kindly record a quick video or something so we can understand how much of an improvement it is over the default voices?

C-Nedelcu commented 1 year ago

Hello there,

I have added ElevenLabs API support in v2.6.0. It's been requested by a lot of people, and I believe it's as good as (if not better than) Amazon Polly.

Considering this, do you still feel that Amazon Polly integration is useful? If not, I will close the issue.

C-Nedelcu commented 1 year ago

closed due to inactivity. Feel free to reopen later if necessary