appatalks/chatgpt-html

Bark Speech integration

Closed this issue · 3 comments

Very close:

<button onclick="barkTTS()">Click me</button>

<audio id="audioPlayer" type="audio/wav"></audio>

<script>
  function barkTTS() {
    const url = 'http://127.0.0.1:8080/send-string';
    const data = txtOutput.innerHTML;
    const xhr = new XMLHttpRequest();
    xhr.responseType = 'blob';
    xhr.onload = function() {
      const audioElement = new Audio("./audio/bark_audio.wav");
      audioElement.play();
    }
    xhr.open('POST', url, true);
    xhr.setRequestHeader('Content-Type', 'text/plain');
    xhr.send(data);
  }
</script>

https://github.com/servingbaby/Bark_text-to-speech
https://github.com/suno-ai/bark

Added to main. Currently I am unable to use the auto-speech function.

Need to figure out how to handle the audio file. Challenge is trying to deleting it or using in memory as it sometimes talks over itself from previous file generation.

Another issue, Android Browsers (except for "Firefox Focus") don't seem to honor no cache rules - so the old wav file keeps getting played.

Happy with current implementation. Will revisit later when more matured.