Hearing Example

Transcribing Audio

Suppose we have an audio file called realboy.mp3 that contains the sentence "I'm a real boy".


Terminal (via CURL)

curl -X POST \
  "https://api.geppetto.app/hear" \
  -H "Authorization: Bearer ${GEPPETTO_API_KEY}" \
  -F file="@realboy.mp3"

The output will be a JSON object

{"text":" I'm a real boy.\n"}

Python

import os
import requests
 
GEPPETTO_API_KEY = os.environ.get("GEPPETTO_API_KEY")
 
url = 'https://api.geppetto.app/hear'
headers = {
  "Authorization": f"Bearer {GEPPETTO_API_KEY}"
}
 
files = {
  "file": ("realboy.mp3", open("realboy.mp3", "rb"), "audio/mpeg")
}
 
response = requests.post(url, headers=headers, files=files)
print(response.json())

Node.js

  1. Install the Geppetto Typescript Library
npm install @geppetto-app/geppetto
  1. Use the library to transcribe the audio
import fs from "fs";
import { Geppetto } from "@geppetto-app/geppetto";
 
const geppetto = new Geppetto();
 
async function main() {
  const file = fs.readFileSync("speech.mp3");
  const response = await geppetto.hear({ file });
 
  console.log(response);
}
 
main();