joshbenner851
joshbenner851

Reputation: 111

How to extract/download audio that's played by JS?

How do you download the audio from html5 or however this audio of text-to-speech is working on this site? https://ttsreader.com/

I'm trying to automate some testing with real audio to test on Amazon Alexa, and so I need a huge sample set of audio files. So I have all the permutations of the phrases I want to try, but I need different voices for each one.

I found https://ttsreader.com/ and I like the variety and natural voices they have, but I can't figure out how to programmatically download the text-to-speech audio when the voice plays.

I'm planning on downloading like 6k audio files between all the different voices so I definitely need to script this somehow, as their suggested way through Audacity would be far too time consuming.

Upvotes: 2

Views: 2444

Answers (2)

joshbenner851
joshbenner851

Reputation: 111

Soooo this is specific to if you have a Mac and you're happy with the voices Apple provides, but I was enlightened to the command say which allows you to download audio files in different voices.

Just run man say to see all your options for exporting/etc, and say -v ? to see all the voices.

This guide tells you how to download more voices

Break out a quick bash script and you're all set to go

# A = item you want Alexa to be changing,   B = Voices available
A=(Potatoes Steak Carrots) B=(Fiona Serena Daniel)
nameLength=${#A[@]}
voiceLength=${#B[@]}

for((i=0;i<$nameLength;i++)); do 
   for((x=0;x<$voiceLength;x++)); do 
      say "Alexa, ask spartycafe to log ${A[$i]}" -v ${B[$x]} -o ${A[$i]}$B$x.m4a; 
   done ;
done

Upvotes: 3

guest271314
guest271314

Reputation: 1

You can use navigator.mediaDevices.getUserMedia() with settings object {audio:true}, MediaRecorder(). At navigator.mediaDevices() permissions prompt select Monitor of Built-in Audio Analog Stereo to record to record MediaStream of audio output of the output to speakers or headphones.

You can alternatively install or create voices at local filesystem and utilize window.speechSynthesis.speak() and SpeechUtterance object with the above approach to record audio output locally.

Or use the approach to record audio output as a visitor at a website.

See also

Upvotes: 0

Related Questions