Skip to main content

Wrapper around LinTO Studio API

Project description

LinTO Studio SDK

LinTO Studio SDK is a wrapper around LinTO Studio API. You can generate an auth token from LinTO Studio in the organization settings.

It is available in Python and Javascript (NodeJS and web browser).

Install

Python

pip install linto

NodeJS or compiled front-end project

npm install @linto-ai/linto

Plain JS in web browser

<script type="module" src="https://unpkg.com/@linto-ai/linto/index.js"></script>

How to use

NodeJS or Web browser

// NodeJS
import LinTO from "@linto-ai/linto"
let linTO = new LinTO({
  authToken: "authToken",
})

// Browser
let linTO = new window.LinTO({
  authToken: "authToken",
})

// Choose depending on your environment

// NodeJS
import fs from "fs"
const file = await fs.openAsBlob("path/to/audio.mp3")

// Browser :
// From an <input type='file'/>
const file = document.getElementById("file").files[0]

const handle = await linTO.transcribe(file)

handle.addEventListener("update", (e) => {
  console.log("Audio transcription processing", e.detail)
})

handle.addEventListener("done", (e) => {
  console.log("Audio transcription completed", e.detail.text)
})

handle.addEventListener("error", (e) => {
  console.log("Error while processing the audio", e.detail)
})

Full example

Python

import os
from linto import LinTO

linTO = LinTO(auth_token="auth_token")

with open("path/to/audio.mp3", "rb") as f:
    file = f.read()

handle = await linTO.transcribe(file)

def on_update(data):
    print("Audio transcription processing", data)

def on_done(data):
    print("Audio transcription completed", data)

def on_error(data):
    print("Error while processing the audio", data)

handle.on("update", on_update)
handle.on("done", on_done)
handle.on("error", on_error)

See complete python script at python/test.js

Documentation

Options in camelCase are the same in pascal_case for Python

Initialisation

// Javascript
linTO = new LinTO({authToken = "auth_token", ...options})
# Python
linTO = LinTO(auth_token="auth_token", **options)

Options

Parameter required value description default value
authToken yes String Studio auth token
baseUrl no String Studio API base url https://studio.linto.ai/cm-api

Transcribe

// Javascript
const handle = await linTO.transcribe(file, { ...options })

handle.addEventListener("update", callback)
handle.addEventListener("done", callback)
handle.addEventListener("error", callback)
# Python
await linTO.transcribe(file, **options)

handle.on("update", callback)
handle.on("done", callback)
handle.on("error", callback)

Options

Parameter required value description default value
file yes File or Blob Audio file to transcribe
enableDiarization no Bool Enable speaker diarization True
numberOfSpeaker no Int Number of speaker for diarization, 0 means auto 0
language no 2 letters language code or "*" Language the audio should be transcribed. "*" means auto-detection + multiple languages "*"
enablePunctuation no Bool Enable automatic punctuation recognition True
name no String Name of the media in LinTO Studio "imported file ${date}"

Callbacks event value

Callbacks receive a media object with 3 main properties:

  • jobs
  • speakers
  • text
{
  "jobs": {
    "transcription": {
      "state": "done"
      // ...
    }
  },
  "speakers": [
    // array of speakers
    {
      "speaker_id": "60ac8c45-751e-4cf9-8617-833313dd2d12",
      "speaker_name": "speaker",
      "stime": 0,
      "etime": 16.23
    }
  ],
  "text": [
    // array of segments
    {
      "speaker_id": "60ac8c45-751e-4cf9-8617-833313dd2d12",
      "raw_segment": "bonjour je vais donner quelques chiffres hum deux cinq et je vais en donner encore d' autres huit douze un petit dernier dix mille",
      "segment": "bonjour je vais donner quelques chiffres hum 2 5 et je vais en donner encore d'autres 8 12 un petit dernier 10000",
      "words": [
        {
          "wid": "0d7ea137-ea70-467e-b3a0-8646a38a7bcb",
          "stime": 0,
          "etime": 1.41,
          "word": "bonjour",
          "confidence": 1,
          "highlights": [],
          "keywords": []
        },
        {
          "wid": "ea7f448d-a89b-4272-b8bb-f5d4d99e0504",
          "stime": 1.41,
          "etime": 1.44,
          "word": "je",
          "confidence": 1,
          "highlights": [],
          "keywords": []
        }
        // ...
      ]
    }
  ]
}

Full object is described in the API swagger

Coming soon 🏗️

Transcribe video conference

const meeting = await linTO.transcribeVideoConference({ type, url, ...options })
meeting.addEventListener("connected", callback)
meeting.addEventListener("meeting_start", callback)
meeting.addEventListener("people_join", callback)
meeting.addEventListener("meeting_end", callback)
meeting.addEventListener("transcription", callback)

handle = await meeting.offlineTranscription({ ...options })
handle.addEventListener("update", callback)
handle.addEventListener("done", callback)
handle.addEventListener("error", callback)

Live transcription

const live = await linTO.transcribeLive({ ...option })
live.connectAudio(source)
live.startTranscription()
live.stopTranscription()
live.addEventListener("transcription", callback)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

linto-1.0.0.tar.gz (20.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

linto-1.0.0-py3-none-any.whl (19.1 kB view details)

Uploaded Python 3

File details

Details for the file linto-1.0.0.tar.gz.

File metadata

  • Download URL: linto-1.0.0.tar.gz
  • Upload date:
  • Size: 20.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.0

File hashes

Hashes for linto-1.0.0.tar.gz
Algorithm Hash digest
SHA256 2ed75dee12756fd0b3cca7195c8624fbb78c3e37198009aecf513c409154118c
MD5 02745c9929787cb2a1b2546db6d2f1bc
BLAKE2b-256 59c9ee97b0a6be5217a76e133dbf9e5fcf50532c86e89f1314c27fa61dbf8d6a

See more details on using hashes here.

File details

Details for the file linto-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: linto-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 19.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.0

File hashes

Hashes for linto-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ced0f457814dee4f906caa49c4ffec3507524717ecc36ba1f98cb502d8d614cb
MD5 ffec80be71dea0dbfc2c46aab56358dc
BLAKE2b-256 b7ce21c0d3301ef36120b4a7509ef45e1cf7d8b15a6871b86af0225125dbaee4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page