why text to speech sounds worse on phone calls (and how to check it in python)

why text to speech sounds worse on phone calls (and how to check it in python)

why text to speech sounds worse on phone calls (and how to check it in python)

published

published

your voice agent sounds great when you test it on your laptop. then it goes out over a real phone line and sounds... different. same text, same voice. the phone line strips out the top end of the sound.

but most advice on text to speech for phone calls is a checklist, and the tests people publish use english lines. almost nobody checks whether hinglish otps, lakh amounts and pincodes still come out right.

so we'll write a small python script that saves every line twice, once normal and once in the phone's own audio format, so you can listen side by side. then we'll match the format to twilio or exotel and make one real call.

what a phone line does to your text to speech

a narrowband phone path carries 8 kHz audio, so the 24 kHz wav you hear in the rumik silk playground is fuller than what your caller gets. a developer put it well on reddit: "so many people benchmark in the api playground and then are shocked when exotel compression makes it sound different".

here's the same otp line both ways, [neutral] Aapka OTP "482093" hai. from muga:

then the 8 kHz mu-law version decoded to wav. the phone one sounds thinner. the digits are still read one by one.

why thinner? an 8 kHz sample rate can't carry anything above 4 kHz, so the crisp top end of a voice just isn't there. the phone version is usually mu-law, one of the two companding forms of g.711.

the good news: silk hands you the phone format directly. one extra field, "audio_format": "mulaw", on the same request gets you 8 kHz g.711 bytes back. our audio formats reference lists what each value returns. that's a local preview, though. the carrier and handset add their own effects on top, which is why the last step is a real call.

before you start

you need python, your rumik api key, and two packages: requests to call silk and numpy to decode mu-law.

your rumik api key lives under api keys in the rumik dashboard (rumik quickstart). the full key only shows once, when you create it, so copy it then.

# terminal
python -m pip install requests numpy
# terminal
python -m pip install requests numpy

we'll keep the key in the shell environment so it never sits inside the script. in windows powershell:

# powershell
$env:RUMIK_API_KEY = Read-Host "rumik api key"
# powershell
$env:RUMIK_API_KEY = Read-Host "rumik api key"

on mac or linux it's this bash version (if your mac terminal opens in zsh, type bash first):

# terminal
read -r -s -p "rumik api key: " RUMIK_API_KEY
export RUMIK_API_KEY
# terminal
read -r -s -p "rumik api key: " RUMIK_API_KEY
export RUMIK_API_KEY

the key only lives in this terminal, so a new window means setting it again.

how to compare your hinglish lines in python

rumik silk returns a default 24 kHz wav or raw 8 kHz mu-law from the same endpoint, so our phone_check.py asks for both. we'll build it in three steps: one otp in the phone format so you hear a result right away, then the list of risky lines, then the full script that saves every line both ways.

1. save one otp as a playable phone-format wav

the first version asks silk for the otp as raw 8 kHz mu-law, keeps those bytes (that's what a phone stream wants), and decodes a copy into a wav your audio player can open. we're using our muga model with the [neutral] tone prefix, at temperature 0.7 to match our recorded examples. save this as phone_check.py:

# phone_check.py
import os
import wave
from pathlib import Path

import numpy as np
import requests


def mulaw_to_pcm16(raw: bytes) -> np.ndarray:
    u = ~np.frombuffer(raw, dtype=np.uint8)
    sign = u & 0x80
    exponent = (u >> 4) & 0x07
    mantissa = u & 0x0F
    magnitude = ((mantissa.astype(np.int32) << 3) + 0x84) << exponent
    return np.where(sign != 0, 0x84 - magnitude, magnitude - 0x84).astype(np.int16)


def save_phone(raw: bytes, filename: str) -> None:
    pcm = mulaw_to_pcm16(raw)
    with wave.open(filename, "wb") as output:
        output.setnchannels(1)
        output.setsampwidth(2)
        output.setframerate(8000)
        output.writeframes(pcm.astype("<i2").tobytes())


TEXT = '[neutral] Aapka OTP "482093" hai.'
HEADERS = {"Authorization": f"Bearer {os.environ['RUMIK_API_KEY']}"}
response = requests.post(
    "https://silk-api.rumik.ai/v1/tts",
    headers=HEADERS,
    json={"model": "muga", "text": TEXT, "temperature": 0.7, "audio_format": "mulaw"},
    timeout=90,
)
response.raise_for_status()
Path("otp.mulaw").write_bytes(response.content)
save_phone(response.content, "otp-phone.wav")
print("saved otp.mulaw and otp-phone.wav")
# phone_check.py
import os
import wave
from pathlib import Path

import numpy as np
import requests


def mulaw_to_pcm16(raw: bytes) -> np.ndarray:
    u = ~np.frombuffer(raw, dtype=np.uint8)
    sign = u & 0x80
    exponent = (u >> 4) & 0x07
    mantissa = u & 0x0F
    magnitude = ((mantissa.astype(np.int32) << 3) + 0x84) << exponent
    return np.where(sign != 0, 0x84 - magnitude, magnitude - 0x84).astype(np.int16)


def save_phone(raw: bytes, filename: str) -> None:
    pcm = mulaw_to_pcm16(raw)
    with wave.open(filename, "wb") as output:
        output.setnchannels(1)
        output.setsampwidth(2)
        output.setframerate(8000)
        output.writeframes(pcm.astype("<i2").tobytes())


TEXT = '[neutral] Aapka OTP "482093" hai.'
HEADERS = {"Authorization": f"Bearer {os.environ['RUMIK_API_KEY']}"}
response = requests.post(
    "https://silk-api.rumik.ai/v1/tts",
    headers=HEADERS,
    json={"model": "muga", "text": TEXT, "temperature": 0.7, "audio_format": "mulaw"},
    timeout=90,
)
response.raise_for_status()
Path("otp.mulaw").write_bytes(response.content)
save_phone(response.content, "otp-phone.wav")
print("saved otp.mulaw and otp-phone.wav")

running python phone_check.py writes two files. otp.mulaw is the raw phone audio, and otp-phone.wav is the same audio as a mono, 16-bit, 8000 Hz wav. your file is a fresh take, so listen for the otp as separate digits and compare it with our recorded reading.

2. pick the lines that can go wrong

one otp proves the idea. your agent says a lot more than that, so the final version runs your whole list (an otp, a lakh amount, a pincode, a time slot and a vehicle plate) and also saves silk's default wav, which you get by leaving audio_format out. each line ends up with three files: the default wav, the raw .mulaw, and the decoded -phone.wav.

silk's number and date rules decide how each one is read. identifiers go in double quotes so they're read digit by digit, and amounts stay plain so they're read as amounts. the plate gets two extra takes, because letters and digits together are exactly the kind of line i want to hear more than once before a caller does.

3. save every line in both formats

with the list ready, the full script loops over it and saves all three files per line. it stops at the first failed request, so an error body never gets saved as a "wav". every take is another synthesis request, and we bill for the characters you submit, with no extra charge for the phone format (pay-as-you-go reference).

the complete file below replaces everything in phone_check.py. run it with the same command as before:

# terminal
python phone_check.py
# terminal
python phone_check.py
# phone_check.py
import os
import wave
from pathlib import Path

import numpy as np
import requests


ENDPOINT = "https://silk-api.rumik.ai/v1/tts"
HEADERS = {"Authorization": f"Bearer {os.environ['RUMIK_API_KEY']}"}
TEST_LINES = [
    ("otp", '[neutral] Aapka OTP "482093" hai.'),
    ("lakh", "[neutral] Rs 2,45,600 aapke account se debit hue."),
    ("pincode", '[neutral] Delivery pincode "560102" hai na?'),
    ("slot", "[neutral] Aapka slot kal 18:45 par confirm hai."),
    ("vehicle", '[neutral] Gaadi number "MH12AB4567" hai.'),
]


def mulaw_to_pcm16(raw: bytes) -> np.ndarray:
    u = ~np.frombuffer(raw, dtype=np.uint8)
    sign = u & 0x80
    exponent = (u >> 4) & 0x07
    mantissa = u & 0x0F
    magnitude = ((mantissa.astype(np.int32) << 3) + 0x84) << exponent
    return np.where(sign != 0, 0x84 - magnitude, magnitude - 0x84).astype(np.int16)


def save_phone(raw: bytes, filename: str) -> None:
    pcm = mulaw_to_pcm16(raw)
    with wave.open(filename, "wb") as output:
        output.setnchannels(1)
        output.setsampwidth(2)
        output.setframerate(8000)
        output.writeframes(pcm.astype("<i2").tobytes())


def synthesize(text: str, audio_format=None) -> bytes:
    payload = {"model": "muga", "text": text, "temperature": 0.7}
    if audio_format is not None:
        payload["audio_format"] = audio_format
    response = requests.post(
        ENDPOINT, headers=HEADERS, json=payload, timeout=90,
    )
    response.raise_for_status()
    return response.content


def save_pair(clip_id: str, text: str) -> None:
    wav_name = f"{clip_id}-wav.wav"
    raw_name = f"{clip_id}.mulaw"
    phone_name = f"{clip_id}-phone.wav"
    Path(wav_name).write_bytes(synthesize(text))
    raw = synthesize(text, "mulaw")
    Path(raw_name).write_bytes(raw)
    save_phone(raw, phone_name)
    print(f"saved {wav_name}, {raw_name}, and {phone_name}")


def main() -> None:
    for clip_id, text in TEST_LINES:
        save_pair(clip_id, text)
    plate_text = TEST_LINES[-1][1]
    for take in (2, 3):
        save_pair(f"vehicle-take-{take}", plate_text)


if __name__ == "__main__":
    main()
# phone_check.py
import os
import wave
from pathlib import Path

import numpy as np
import requests


ENDPOINT = "https://silk-api.rumik.ai/v1/tts"
HEADERS = {"Authorization": f"Bearer {os.environ['RUMIK_API_KEY']}"}
TEST_LINES = [
    ("otp", '[neutral] Aapka OTP "482093" hai.'),
    ("lakh", "[neutral] Rs 2,45,600 aapke account se debit hue."),
    ("pincode", '[neutral] Delivery pincode "560102" hai na?'),
    ("slot", "[neutral] Aapka slot kal 18:45 par confirm hai."),
    ("vehicle", '[neutral] Gaadi number "MH12AB4567" hai.'),
]


def mulaw_to_pcm16(raw: bytes) -> np.ndarray:
    u = ~np.frombuffer(raw, dtype=np.uint8)
    sign = u & 0x80
    exponent = (u >> 4) & 0x07
    mantissa = u & 0x0F
    magnitude = ((mantissa.astype(np.int32) << 3) + 0x84) << exponent
    return np.where(sign != 0, 0x84 - magnitude, magnitude - 0x84).astype(np.int16)


def save_phone(raw: bytes, filename: str) -> None:
    pcm = mulaw_to_pcm16(raw)
    with wave.open(filename, "wb") as output:
        output.setnchannels(1)
        output.setsampwidth(2)
        output.setframerate(8000)
        output.writeframes(pcm.astype("<i2").tobytes())


def synthesize(text: str, audio_format=None) -> bytes:
    payload = {"model": "muga", "text": text, "temperature": 0.7}
    if audio_format is not None:
        payload["audio_format"] = audio_format
    response = requests.post(
        ENDPOINT, headers=HEADERS, json=payload, timeout=90,
    )
    response.raise_for_status()
    return response.content


def save_pair(clip_id: str, text: str) -> None:
    wav_name = f"{clip_id}-wav.wav"
    raw_name = f"{clip_id}.mulaw"
    phone_name = f"{clip_id}-phone.wav"
    Path(wav_name).write_bytes(synthesize(text))
    raw = synthesize(text, "mulaw")
    Path(raw_name).write_bytes(raw)
    save_phone(raw, phone_name)
    print(f"saved {wav_name}, {raw_name}, and {phone_name}")


def main() -> None:
    for clip_id, text in TEST_LINES:
        save_pair(clip_id, text)
    plate_text = TEST_LINES[-1][1]
    for take in (2, 3):
        save_pair(f"vehicle-take-{take}", plate_text)


if __name__ == "__main__":
    main()

when it finishes, play each -wav.wav next to its -phone.wav. each request generates fresh speech, so they're two takes of the same text, just like a live agent on every call.

with lakh-wav.wav and lakh-phone.wav, you're listening for the amount in lakh, with rupees at the end. for the plate, check that all three takes spell out the letters and digits. the table below shows what you should hear.

the same number readings in both formats

with muga and normalization on, rumik silk read every input below the same way in the 24 kHz wav and the 8 kHz mu-law. the phone format changed how the voice sounds, not what it said.

exact input

24 kHz wav reading

8 kHz mu-law reading

[neutral] Aapka OTP "482093" hai.

four eight two zero nine three

four eight two zero nine three

[neutral] Rs 2,45,600 aapke account se debit hue.

two lakh forty five thousand six hundred rupees

two lakh forty five thousand six hundred rupees

[neutral] Aapka EMI ₹14,850 due hai.

fourteen thousand eight hundred fifty rupees

fourteen thousand eight hundred fifty rupees

[neutral] Delivery pincode "560102" hai na?

five six zero one zero two

five six zero one zero two

[neutral] Aapka slot kal 18:45 par confirm hai.

six forty five pm

six forty five pm

[neutral] Gaadi number "MH12AB4567" hai.

m h one two a b four five six seven

m h one two a b four five six seven

the plate is the line with the most going on, so we checked more of it, and our extra takes in both formats give the same reading. still, a live agent makes new speech on every call, so for ids that mix letters and digits, i listen to a few takes, not one.

we ran every complete script in this article with a real rumik api key, on muga at temperature 0.7 over the http endpoint, and every reading shown here was checked. we didn't place a phone call for this test, so these results don't cover carrier processing, packet loss, handset playback or latency.

which audio format does your phone path need?

hearing the phone version is half the job. the other half is sending your provider the exact bytes it expects: rumik silk's mulaw output fits twilio media streams once it's base64 encoded, and exotel's voicebot applet wants linear pcm at whatever sample rate you configured.

silk audio branches into local playback and two provider stream formats

destination

expected audio

silk setting

conversion you do

twilio media streams

raw 8 kHz mono mu-law, base64-encoded

mulaw

base64-encode the raw bytes

exotel voicebot, default 8000 Hz

raw mono 16-bit little-endian pcm, base64-encoded

mulaw

decode to pcm, then base64-encode

exotel voicebot, ?sample-rate=24000

raw mono 16-bit little-endian pcm at 24 kHz, base64-encoded

pcm

base64-encode the raw bytes

local preview of a prerecorded ivr line

playable wav

omit the field, or decode mulaw

save the default wav, or write the decoded wav

twilio's media stream specification asks for audio/x-mulaw at 8000 Hz, which is exactly what our .mulaw files already are. all they need is base64. don't send the -phone.wav though. that file is for your ears, and its wav header doesn't belong in twilio's payload.

exotel's voicebot applet specification expects linear pcm audio, which is just the decoded samples. at exotel's default 8000 Hz, our decoder already gives you those samples before it adds the wav header. or skip the decoding: ask silk for pcm and set exotel to ?sample-rate=24000. either way, exotel wants chunks in multiples of 320 bytes, at least 3.2 KB and at most 100 KB each.

fix rejected formats and unplayable files

two things trip people up here. if you get 400 UNSUPPORTED_AUDIO_FORMAT, the request asked for something silk doesn't serve. null counts, and so do wav and ogg. when you want the default wav, leave audio_format out entirely, the way our script does. for streaming, the format is set once, when you create the streaming session, and later frames can't change it.

and if a .mulaw file won't play, that's expected. it has no header, and renaming it to .wav won't fix that. save_phone in our script decodes it into a mono, 16-bit, 8000 Hz wav. that rate matters: a player told those samples are 24 kHz plays them at the wrong speed.

make one real call before you ship

a real call is the one check that covers the carrier and the handset. put your test line in the plain-text greeting of a rumik silk agent that uses muga or mulberry and deploy it (agent setup docs).

then call yourself with the rumik outbound call api: POST /v1/calls with the agent's agentId and your own number as toNumber in E.164 format. you don't need to rent a number, since the platform's shared number is used when the agent has none. pick up and listen to the greeting the way your callers will.

already running calls through your own twilio or exotel integration? make this last call through that instead, with silk's audio in the format from the table above. that's the check that proves your own pipeline sends and plays it right.

if you want more silk examples after that, our python text-to-speech tutorial has them.

your voice agent sounds great when you test it on your laptop. then it goes out over a real phone line and sounds... different. same text, same voice. the phone line strips out the top end of the sound.

but most advice on text to speech for phone calls is a checklist, and the tests people publish use english lines. almost nobody checks whether hinglish otps, lakh amounts and pincodes still come out right.

so we'll write a small python script that saves every line twice, once normal and once in the phone's own audio format, so you can listen side by side. then we'll match the format to twilio or exotel and make one real call.

what a phone line does to your text to speech

a narrowband phone path carries 8 kHz audio, so the 24 kHz wav you hear in the rumik silk playground is fuller than what your caller gets. a developer put it well on reddit: "so many people benchmark in the api playground and then are shocked when exotel compression makes it sound different".

here's the same otp line both ways, [neutral] Aapka OTP "482093" hai. from muga:

then the 8 kHz mu-law version decoded to wav. the phone one sounds thinner. the digits are still read one by one.

why thinner? an 8 kHz sample rate can't carry anything above 4 kHz, so the crisp top end of a voice just isn't there. the phone version is usually mu-law, one of the two companding forms of g.711.

the good news: silk hands you the phone format directly. one extra field, "audio_format": "mulaw", on the same request gets you 8 kHz g.711 bytes back. our audio formats reference lists what each value returns. that's a local preview, though. the carrier and handset add their own effects on top, which is why the last step is a real call.

before you start

you need python, your rumik api key, and two packages: requests to call silk and numpy to decode mu-law.

your rumik api key lives under api keys in the rumik dashboard (rumik quickstart). the full key only shows once, when you create it, so copy it then.

# terminal
python -m pip install requests numpy

we'll keep the key in the shell environment so it never sits inside the script. in windows powershell:

# powershell
$env:RUMIK_API_KEY = Read-Host "rumik api key"

on mac or linux it's this bash version (if your mac terminal opens in zsh, type bash first):

# terminal
read -r -s -p "rumik api key: " RUMIK_API_KEY
export RUMIK_API_KEY

the key only lives in this terminal, so a new window means setting it again.

how to compare your hinglish lines in python

rumik silk returns a default 24 kHz wav or raw 8 kHz mu-law from the same endpoint, so our phone_check.py asks for both. we'll build it in three steps: one otp in the phone format so you hear a result right away, then the list of risky lines, then the full script that saves every line both ways.

1. save one otp as a playable phone-format wav

the first version asks silk for the otp as raw 8 kHz mu-law, keeps those bytes (that's what a phone stream wants), and decodes a copy into a wav your audio player can open. we're using our muga model with the [neutral] tone prefix, at temperature 0.7 to match our recorded examples. save this as phone_check.py:

# phone_check.py
import os
import wave
from pathlib import Path

import numpy as np
import requests


def mulaw_to_pcm16(raw: bytes) -> np.ndarray:
    u = ~np.frombuffer(raw, dtype=np.uint8)
    sign = u & 0x80
    exponent = (u >> 4) & 0x07
    mantissa = u & 0x0F
    magnitude = ((mantissa.astype(np.int32) << 3) + 0x84) << exponent
    return np.where(sign != 0, 0x84 - magnitude, magnitude - 0x84).astype(np.int16)


def save_phone(raw: bytes, filename: str) -> None:
    pcm = mulaw_to_pcm16(raw)
    with wave.open(filename, "wb") as output:
        output.setnchannels(1)
        output.setsampwidth(2)
        output.setframerate(8000)
        output.writeframes(pcm.astype("<i2").tobytes())


TEXT = '[neutral] Aapka OTP "482093" hai.'
HEADERS = {"Authorization": f"Bearer {os.environ['RUMIK_API_KEY']}"}
response = requests.post(
    "https://silk-api.rumik.ai/v1/tts",
    headers=HEADERS,
    json={"model": "muga", "text": TEXT, "temperature": 0.7, "audio_format": "mulaw"},
    timeout=90,
)
response.raise_for_status()
Path("otp.mulaw").write_bytes(response.content)
save_phone(response.content, "otp-phone.wav")
print("saved otp.mulaw and otp-phone.wav")

running python phone_check.py writes two files. otp.mulaw is the raw phone audio, and otp-phone.wav is the same audio as a mono, 16-bit, 8000 Hz wav. your file is a fresh take, so listen for the otp as separate digits and compare it with our recorded reading.

2. pick the lines that can go wrong

one otp proves the idea. your agent says a lot more than that, so the final version runs your whole list (an otp, a lakh amount, a pincode, a time slot and a vehicle plate) and also saves silk's default wav, which you get by leaving audio_format out. each line ends up with three files: the default wav, the raw .mulaw, and the decoded -phone.wav.

silk's number and date rules decide how each one is read. identifiers go in double quotes so they're read digit by digit, and amounts stay plain so they're read as amounts. the plate gets two extra takes, because letters and digits together are exactly the kind of line i want to hear more than once before a caller does.

3. save every line in both formats

with the list ready, the full script loops over it and saves all three files per line. it stops at the first failed request, so an error body never gets saved as a "wav". every take is another synthesis request, and we bill for the characters you submit, with no extra charge for the phone format (pay-as-you-go reference).

the complete file below replaces everything in phone_check.py. run it with the same command as before:

# terminal
python phone_check.py
# phone_check.py
import os
import wave
from pathlib import Path

import numpy as np
import requests


ENDPOINT = "https://silk-api.rumik.ai/v1/tts"
HEADERS = {"Authorization": f"Bearer {os.environ['RUMIK_API_KEY']}"}
TEST_LINES = [
    ("otp", '[neutral] Aapka OTP "482093" hai.'),
    ("lakh", "[neutral] Rs 2,45,600 aapke account se debit hue."),
    ("pincode", '[neutral] Delivery pincode "560102" hai na?'),
    ("slot", "[neutral] Aapka slot kal 18:45 par confirm hai."),
    ("vehicle", '[neutral] Gaadi number "MH12AB4567" hai.'),
]


def mulaw_to_pcm16(raw: bytes) -> np.ndarray:
    u = ~np.frombuffer(raw, dtype=np.uint8)
    sign = u & 0x80
    exponent = (u >> 4) & 0x07
    mantissa = u & 0x0F
    magnitude = ((mantissa.astype(np.int32) << 3) + 0x84) << exponent
    return np.where(sign != 0, 0x84 - magnitude, magnitude - 0x84).astype(np.int16)


def save_phone(raw: bytes, filename: str) -> None:
    pcm = mulaw_to_pcm16(raw)
    with wave.open(filename, "wb") as output:
        output.setnchannels(1)
        output.setsampwidth(2)
        output.setframerate(8000)
        output.writeframes(pcm.astype("<i2").tobytes())


def synthesize(text: str, audio_format=None) -> bytes:
    payload = {"model": "muga", "text": text, "temperature": 0.7}
    if audio_format is not None:
        payload["audio_format"] = audio_format
    response = requests.post(
        ENDPOINT, headers=HEADERS, json=payload, timeout=90,
    )
    response.raise_for_status()
    return response.content


def save_pair(clip_id: str, text: str) -> None:
    wav_name = f"{clip_id}-wav.wav"
    raw_name = f"{clip_id}.mulaw"
    phone_name = f"{clip_id}-phone.wav"
    Path(wav_name).write_bytes(synthesize(text))
    raw = synthesize(text, "mulaw")
    Path(raw_name).write_bytes(raw)
    save_phone(raw, phone_name)
    print(f"saved {wav_name}, {raw_name}, and {phone_name}")


def main() -> None:
    for clip_id, text in TEST_LINES:
        save_pair(clip_id, text)
    plate_text = TEST_LINES[-1][1]
    for take in (2, 3):
        save_pair(f"vehicle-take-{take}", plate_text)


if __name__ == "__main__":
    main()

when it finishes, play each -wav.wav next to its -phone.wav. each request generates fresh speech, so they're two takes of the same text, just like a live agent on every call.

with lakh-wav.wav and lakh-phone.wav, you're listening for the amount in lakh, with rupees at the end. for the plate, check that all three takes spell out the letters and digits. the table below shows what you should hear.

the same number readings in both formats

with muga and normalization on, rumik silk read every input below the same way in the 24 kHz wav and the 8 kHz mu-law. the phone format changed how the voice sounds, not what it said.

exact input

24 kHz wav reading

8 kHz mu-law reading

[neutral] Aapka OTP "482093" hai.

four eight two zero nine three

four eight two zero nine three

[neutral] Rs 2,45,600 aapke account se debit hue.

two lakh forty five thousand six hundred rupees

two lakh forty five thousand six hundred rupees

[neutral] Aapka EMI ₹14,850 due hai.

fourteen thousand eight hundred fifty rupees

fourteen thousand eight hundred fifty rupees

[neutral] Delivery pincode "560102" hai na?

five six zero one zero two

five six zero one zero two

[neutral] Aapka slot kal 18:45 par confirm hai.

six forty five pm

six forty five pm

[neutral] Gaadi number "MH12AB4567" hai.

m h one two a b four five six seven

m h one two a b four five six seven

the plate is the line with the most going on, so we checked more of it, and our extra takes in both formats give the same reading. still, a live agent makes new speech on every call, so for ids that mix letters and digits, i listen to a few takes, not one.

we ran every complete script in this article with a real rumik api key, on muga at temperature 0.7 over the http endpoint, and every reading shown here was checked. we didn't place a phone call for this test, so these results don't cover carrier processing, packet loss, handset playback or latency.

which audio format does your phone path need?

hearing the phone version is half the job. the other half is sending your provider the exact bytes it expects: rumik silk's mulaw output fits twilio media streams once it's base64 encoded, and exotel's voicebot applet wants linear pcm at whatever sample rate you configured.

silk audio branches into local playback and two provider stream formats

destination

expected audio

silk setting

conversion you do

twilio media streams

raw 8 kHz mono mu-law, base64-encoded

mulaw

base64-encode the raw bytes

exotel voicebot, default 8000 Hz

raw mono 16-bit little-endian pcm, base64-encoded

mulaw

decode to pcm, then base64-encode

exotel voicebot, ?sample-rate=24000

raw mono 16-bit little-endian pcm at 24 kHz, base64-encoded

pcm

base64-encode the raw bytes

local preview of a prerecorded ivr line

playable wav

omit the field, or decode mulaw

save the default wav, or write the decoded wav

twilio's media stream specification asks for audio/x-mulaw at 8000 Hz, which is exactly what our .mulaw files already are. all they need is base64. don't send the -phone.wav though. that file is for your ears, and its wav header doesn't belong in twilio's payload.

exotel's voicebot applet specification expects linear pcm audio, which is just the decoded samples. at exotel's default 8000 Hz, our decoder already gives you those samples before it adds the wav header. or skip the decoding: ask silk for pcm and set exotel to ?sample-rate=24000. either way, exotel wants chunks in multiples of 320 bytes, at least 3.2 KB and at most 100 KB each.

fix rejected formats and unplayable files

two things trip people up here. if you get 400 UNSUPPORTED_AUDIO_FORMAT, the request asked for something silk doesn't serve. null counts, and so do wav and ogg. when you want the default wav, leave audio_format out entirely, the way our script does. for streaming, the format is set once, when you create the streaming session, and later frames can't change it.

and if a .mulaw file won't play, that's expected. it has no header, and renaming it to .wav won't fix that. save_phone in our script decodes it into a mono, 16-bit, 8000 Hz wav. that rate matters: a player told those samples are 24 kHz plays them at the wrong speed.

make one real call before you ship

a real call is the one check that covers the carrier and the handset. put your test line in the plain-text greeting of a rumik silk agent that uses muga or mulberry and deploy it (agent setup docs).

then call yourself with the rumik outbound call api: POST /v1/calls with the agent's agentId and your own number as toNumber in E.164 format. you don't need to rent a number, since the platform's shared number is used when the agent has none. pick up and listen to the greeting the way your callers will.

already running calls through your own twilio or exotel integration? make this last call through that instead, with silk's audio in the format from the table above. that's the check that proves your own pipeline sends and plays it right.

if you want more silk examples after that, our python text-to-speech tutorial has them.

frequently asked questions

frequently asked questions

frequently asked questions

rumik silk is built for it. its muga model reads hinglish otps digit by digit, amounts in lakh with rupees at the end, and pincodes, times and vehicle plates the way an indian caller expects. it also returns audio in the phone's own format from the same request, and in our tests every one of those readings stayed the same in both.
text to speech sounds thinner on any phone call, because 8 kHz phone audio can't carry the high frequencies. what matters is whether the words survive. with rumik silk the otps, amounts, pincodes, times and plates in this article read exactly the same in both formats, so the caller hears a thinner voice saying the right thing.
yes, rumik silk returns raw 8 kHz mu-law when you set the audio format to mulaw, which is exactly what twilio media streams take. you skip the resampling and conversion step and only base64 encode the bytes before you send them.
yes, rumik silk works with exotel's voicebot applet, which takes 16-bit linear pcm. ask silk for pcm and set exotel to a 24000 Hz sample rate, or keep exotel's default 8000 Hz and decode silk's mu-law output to pcm. either way you base64 encode it before sending.
no, rumik silk bills for the characters you submit, and mu-law output costs the same as the normal wav. so you can generate both versions of every line to compare them, and pay only for the extra requests.
yes, deploy a rumik silk agent with your test line as its greeting and call your own number with the rumik outbound call api. you don't need to rent a number for this, because the platform's shared number is used when the agent has none.

read other articles

read other articles

read other articles