Skip to content

Example for client-side encoding of microphone audio into FLAC data

License

Notifications You must be signed in to change notification settings

mmig/speech-to-flac

Repository files navigation

speech-to-flac

Example for client-side encoding microphone audio into FLAC.

This is a demo for JavaScript FLAC encoder libflac.js.

Similar to the Speech-To-File demo, this demo records audio from the microphone and encodes it into FLAC data. The Speech-To-File demo is based on A. Krennmair's Speech-To-Server demo.

When recording is stopped, a download link for the encoded data is triggered.

Encoding etc. works completely client-side, i.e. no data is sent to any server.

As a special option, the FLAC data can be sent to the Google Speech Recognition web service. NOTE that you need to set your (secret) API key for the recognition service first (see comment in app.js for more details).

Demo

Try out at the demo page.

Setup:

  • your device needs a microphone
  • accept, when asked to allow your browser access to the microphone

Setup Speech Recognition (Google Cloud Speech service):

  • you can set the API key / service key via search params in the URL:
    • key: key=<your key>
    • use API key: auth=apiKey
    • use service key: auth=serviceKey (default method)
      • see also the node utility script create_access_token.js
      • NOTE currently, the serviceKey option does work in normal browser environments due to CORS/authentification limitations
  • pre-selected recognition language: language=de-DE
  • examples (append to URL):
    • (access token from service key) ?language=en-GB&key=<access token generated with a service key>
    • (API key, only use in secure env.) ?language=en-GB&auth=apiKey&key=<your API key>
  • NOTE: use the apiKey method for setting the auth/keys only for testing in secure environments & take care to keep your keys secret!!!
    Instead you should set up a service that allows logged in users to retrieve an access token, generated with your service key on your secured server
    (see the examle script create_access_token.js for an example to generate the access token on your server using Node.js)

Usage:

  • select FLAC-file for encoding the audio in FLAC format (or WAV for uncompressed audio)
  • press Start recording will start recording (you may need to allow your browser access to your microphone in this step)
  • pressing Stop recording will open a dialog for downloading the recorded file (FLAC or WAV)
  • note: recording & encoding to FLAC is done all on the client-side (i.e. within your browser); no data is sent to a server.

NOTE: If you access the demo page via https, most browsers will make the permission for accessing your microphone from this page persistent; if accessed via http the permission only lasts until you leave the page (or may even deny access to the microphone altogether).

About

Example for client-side encoding of microphone audio into FLAC data

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published