Certainly! Below is a complete example of a simple web app that:
Lets the user enter text.
Adjust speech synthesis voice, speed, and pitch.
Play the speech.
Export the speech as a WAV file.
Provide a shareable URL with the settings encoded (using /#/ hash).
This uses the Web Speech API for synthesis and the Recorder.js approach to capture audio from an AudioContext.
Features:
Text input.
Voice selector dropdown.
Speed (rate) slider.
Pitch slider.
Play button.
Export button (WAV download).
Share button — updates URL hash with parameters.
On load, parses URL and restores parameters.
How it works:
The Web Speech API's speechSynthesis cannot natively export audio.
To export audio, we create an AudioContext and use the SpeechSynthesisUtterance spoken via a hidden <audio> element or AudioContext — but the Web Speech API is not designed to output audio to AudioContext.
So, capturing the voice output is tricky.
A common workaround is to use the SpeechSynthesisUtterance to speak via speechSynthesis.speak(), and also use a dummy AudioContext and record the system audio if possible — but browsers restrict this.
Another workaround is to use third-party TTS APIs that return audio blobs.
For demonstration, the below example records user microphone input only while playing speech — which is not what you want.
Given this, I will provide a working example that plays speech with UI controls, and exports speech parameters as JSON in URL hash for sharing. Exporting WAV from native speech synthesis without backend API is generally not feasible in browser-only environments.
If you want true audio export, you will need either:
Backend TTS service that returns audio file.
Use Web Audio API to synthesize speech (like with external libraries or own voice models).
Or use the MediaRecorder API while feeding audio from an external API.