Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Any chance you could provide some guidance on how to use this? #1

Open
rpelletierrefocus opened this issue Apr 7, 2021 · 1 comment

Comments

@rpelletierrefocus
Copy link

I have successfully built the Docker image and spun it up, but I do not understand how to process a file. Any help would be greatly appreciated.

@mhilker
Copy link
Owner

mhilker commented Apr 7, 2021

The container process starts a HTTP server (default on port 8080).

Most of the HTTP plumbing happens inside the server handler: https://github.com/mhilker/transcriber/blob/master/cmd/server/main.go#L55

Currently, it works like this:

  • the request method has to be a POST request
  • the content-type has to be audio/webm
  • the body contains just a blob of your audio file

If everything works correct, you will get back a JSON response with an object containing the hypothesis and the score.

I've used the API like this (be aware this is FLOW flavoured JS, your milage may vary):

// @flow

type Transcription = {
  hypothesis: string,
  score: number,
}

const url = process.env.REACT_APP_API_URL || '';

export default async function (blob: Blob): Promise<Transcription> {
  const response = await fetch(url, {
    method: 'POST',
    body: blob,
    headers: {
      'Content-Type': 'audio/webm',
    },
  });
  const json =  await response.json();
  console.log(json);
  return {
    hypothesis: json.hypothesis || '',
    score: json.score || 0.0,
  };
}

Please let me know if this helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants