Skip to navigation

Choose the Script of the Text

View as Markdown

mode decides the script of text and how literal it is. Pick it by where the text goes.

ModeWhat you getUse it for
codemixThe language in its own script, English words in Latin lettersChat and messages: WhatsApp, Slack, email
transcribe (default)One script for everythingA document in one script, search, text that is read aloud
translitLatin letters onlyPeople who type their language in Latin letters (Roman Hindi, Tanglish)
verbatimEvery word as spoken, numbers as words, no editsAn exact record: legal, medical, an ID read aloud

Try the four modes

import os
from sarvamai import SarvamAI
client = SarvamAI(api_subscription_key=os.environ["SARVAM_API_KEY"])
for mode in ["codemix", "transcribe", "translit", "verbatim"]:
with open("voice_note.mp3", "rb") as f:
res = client.dictate.transcribe(file=f, language_code="hi-IN", mode=mode)
print(f"{mode:>10}: {res.text.splitlines()[0][:100]}")
Output
codemix: देखिए भाई साहब, accident में बच्चे का खून काफी बह गया है। आप तो जानती हैं कि AB negative खून बड़ा मु
transcribe: देखिए भाई साहब, एक्सीडेंट में बच्चे का खून काफी बह गया है। आप तो जानती हैं कि AB नेगेटिव खून बड़ा मु
translit: Dekhiye bhai sahab, accident mein bacche ka khoon kaafi beh gaya hai. Aap to jaanti hain ki AB negat
verbatim: देखिए भाई साहब, एक्सीडेंट में बच्चे का खून काफी बह गया है। आप तो जानती हैं कि ए बी नेगेटिव खून बड़ा

Good to know

  • Send language_code when you know it. auto works, but a known language is more reliable.
  • There is no translate mode. To translate, ask for it in style.rules.
  • Write the names in your vocabulary in the script of the mode. With codemix, write English names in Latin letters.
  • The same setting works on the live socket: put mode in the connection settings.