Adding Personality to Text to Speech: Shy and Cat Speech
Also in: 日本語한국어简体中文PortuguêsEspañolFrançaisDeutschРусский
Text to speech has gotten good. The voices sound real, and you can pick a tone before you talk, so a line comes out happy, sad or whispered. But even a good voice reading a clean sentence sounds like someone reading. People don't talk in clean sentences, and characters have quirks.
So I started going past tone and changing the words themselves. The first thing I built is Shy, which puts the hesitations and stutters back into what you say. It's an algorithm I wrote, not an AI rewriting your words, and it changes with the language. A second feature grew out of it, and that one comes later in the post. Here's how it works.
An algorithm for sounding nervous on purpose
The idea was to write an algorithm that makes you sound nervous on purpose, and let you pick how much. In the app that's the Shy tone in AI Voice, with three levels: Slightly, Balanced and Full. It depends on the language, because people don't hesitate the same way in Japanese as in English.
The algorithm runs on your PC in a fraction of a millisecond. It doesn't try to understand what you said. It only checks things like whether a word starts with "th" or a sentence opens on "Wait", and for what it does, that's enough. Speech to text writes down what you said, the algorithm touches that text, and the voice says the result. Your screen always shows the clean version.
Shy
Why
Speech to text is built to produce clean text. That's good for dictation and bad for sounding like a person. The "um" gets smoothed out, a repeated word becomes one word, and a stutter never makes it through. So the voice reads your line like a newsreader, even if you said it nervously. Most of what makes speech sound like a person is exactly what transcription throws away.
Shy puts it back. The "um", the restart, the stutter on the first word, the trailing off. The voice switches to a shy delivery too, quieter and less sure. It also sounds less like AI, since perfectly fluent speech is the main giveaway.
There's another reason. If you talk online with text to speech, there's a decent chance you're a bit shy about your voice. I was. A shy tone fits that person, and in a conversation it's just fun. People react to "I-I wasn't sure you'd come" very differently from the flat version.
What it does
In AI Voice, pick Shy in the Emotion strip on the Speak tab. A pill under it sets how much: Slightly, Balanced or Full.
- You said
- I wasn't sure you'd come. Do you want to play together?
- Slightly
- Um, I wasn't sure you'd come. Do you want to play together?
- Balanced
- I-I wasn't sure you'd come. Uh, do you want to play together?
- Full
- I-I wasn't sure you'd come. Um, do you, do you want to play together?
Shy has six moves. Each one only adds to what you said:
- Filler. "Um", "uh", at the start or in the middle.
- Stutter. The first sound of a word, repeated: "Th-thanks".
- Restart. A few words said twice: "I was, I was going to show you".
- Pause. A comma stretched into a longer break.
- Trail-off. The end of a sentence fades instead of landing.
- Tags. Every sentence gets a [shy] tag so the voice performs it shy. Some stuttered ones get [nervous]. On Full with Ultra realistic, a line can open with a throat clear, and an exclamation can get a shy giggle.
Here's what happens to each sentence. First: does this level touch it at all? Slightly only touches every other one, counted across takes, so quick replies alternate between touched and clean. Balanced and Full touch every sentence.
Then the opener: a filler, a stutter, or nothing. The limits here came from listening. Never two sentences in a row that open on a filler. Never a filler before "Wait" or "Oh", because nobody says "um, wait". Never a stutter on "okay" or "yeah". Below Full, never a filler on top of an opening stutter.
Then maybe one more move: a filler in the middle, a restart, or a pause at a comma. Then maybe a trail-off, never twice in a row, and never on the last sentence on Fast, since that engine stops short instead of fading. Then the tag, and a note of what it did, so the next sentence does something else. That memory is why the same line keeps coming out differently:
- Take 1
- Uh, okay, I'll go first.
- Take 2
- Okay, I-I'll go first.
- Take 3
- Um, okay, I'll go first...
- Take 4
- Okay, uh, I'll go first.
- Take 5
- Okay, I-I'll go first.
The algorithm
All of that is one loop. It goes one sentence at a time and remembers what it did last.
The three levels change the odds per sentence:
| Slightly | Balanced | Full | |
|---|---|---|---|
| Sentences touched | every other | every one | every one |
| Stutter | 50% | 55% | always |
| Filler | 50% | 55% | 85% |
| A second move | no | 35% | 45% |
| Restart | no | 15% | 25% |
| Trail off | no | 12% | 30% |
| Pause at a comma | no | 8% | 15% |
| Double stutter (I-I-I) | no | no | 15% |
| Giggle, throat clear | no | no | 30%, 10% |
Every language hesitates differently
Shy has a version per language, with its own fillers and its own idea of a stutter. English repeats the first sound. Japanese repeats the first kana. Chinese repeats the first character with a comma. Korean the first syllable. Russian stutters with a hyphen, like in a novel.
| Language | Fillers | Example |
|---|---|---|
| English | Um, uh | Th-thanks, uh, for waiting. |
| Japanese | etto, ano, sono (えっと、あの、その) | きょ、今日は一緒に遊べて楽しかった。 "today was fun playing together" |
| Chinese | nàge, e, en, jiùshì (那个、呃、嗯、就是) | 等,等等,你要走了吗? "wait, are you leaving already?" |
| Korean | eum, eo, jeogi, geuge (음, 어, 저기, 그게) | 저, 저기요, 혹시 같이 놀아도 돼요? "excuse me, can I play with you?" |
| Russian | nu, e-e, m-m (Ну, Э-э, М-м) | П-привет, я тут новенький. "hi, I'm new here" |
| German | Ähm, äh, also | H-hallo, äh, ich bin neu hier. "hi, I'm new here" |
| French | Euh, bah, ben, enfin | S-salut, je suis nouveau ici. "hi, I'm new here" |
| Spanish | Eh, pues, bueno, mmm | H-hola, pues, soy nuevo aquí. "hi, I'm new here" |
| Portuguese | É, hum, então, tipo | O-oi, tipo, eu sou novo aqui. "hi, I'm new here" |
The tricky ones were fillers that are also words. In Chinese, nàge (那个) is the most common hesitation, the "um", but it also means "that". If the voice rushes the pause, nàge... rén duō ("um... lots of people") turns into nàge rén duō, "that person". So nàge is only allowed before words like wǒ and nǐ ("I" and "you"). Japanese ano (あの) has the same problem (ano purezento is "that present"), and Russian eto (это) blurs into eto ya, "it's me". Each one has its own check.
Japanese has one more catch. To stutter on 今日 ("today") you need to know it's read kyō, and the text doesn't say. So Shy carries a list of common words and their readings. A word not on the list gets a filler instead of a guess.
Cat speech
Why
Once Shy worked, I wanted to try the same idea on a way of talking that is pure character. One of my favorite character tropes in anime is the cat person, "neko" in Japanese. They say "nya", which I and a lot of avid anime watchers find cute and endearing (those of us who watch with subtitles instead of the dub, anyway), and it colors the conversation in a way that never comes across outside Japanese. Sentences end in nya. A "na" in the middle of a word turns into "nya". A surprised little "nya!" opens a line. Japanese anime has developed this further than anywhere else: there are decades of conventions, and native speakers hear right away whether it's done right.
Chinese has its own version. The cat girl (猫娘, māoniáng) ends her sentences in "miao" (喵), and there's a well-known pun where miào (妙, "wonderful") becomes miāo because they sound alike. But the conventions differ. In Japanese the cat sound lives inside the words. In Chinese it sits at the end of the sentence, like a particle. Korean doesn't really have this style, and when I tried an English version it just sounded weird. So cat speech is Japanese and Chinese only. It's called Neko (ネコ) or Miao Miao (喵喵), under Speech style on the Speak tab, and it shows up when the app is in one of those languages with a matching voice.
- Japanese
- そんなことないです → そんにゃことにゃいですにゃsonna koto nai desu ("no, not at all") → sonya koto nyai desu nya
- Chinese
- 太妙了! → 太喵了喵!tài miào le ("that's wonderful!") → tài miāo le miāo
The algorithm
Both languages use the same algorithm with a different table.
It first looks at the script. Kana means the Japanese table. Only Chinese characters means the Chinese table. Anything else, like an English line or a mix, passes through untouched. Then it rolls. Neko fires on every line, Miao Miao on most of them, so there isn't a miao on every single sentence.
Next comes the ending, which does most of the work. The last word is matched against a table, top to bottom, and the first row that fits wins.
| Japanese (Neko) | Chinese (Miao Miao) | |
|---|---|---|
| Where | Inside words and at the end | At the end of the sentence |
| Endings | The particles ne, yo and ka become nya (ね → にゃ, よ → にゃ, か → かにゃ), polite desu gets nya (です → ですにゃ), anything else just adds nya | The question particles ma and ne become miao (吗 → 喵, 嘛 → 喵, 呢 → 喵), anything else just adds miao |
| Greetings | konnichiwa → konnichi-nya (こんにちは → こんにちにゃ), okaeri ("welcome home") → okaeri-nya | none |
| Inside words (Full) | naruhodo ("I see") → nyaruhodo, minna ("everyone") → minnya, nai ("not") → nyai, and na → nya, nu → nyu, ne → nye in any word, up to 3 per line | miào ("wonderful", 妙) → miāo (喵), shénme ("what", 什么) → shén-miāo (什喵), 1 per line |
| Interjections (Full) | nya! (にゃっ!) on an exclamation, nya? on a question, unya~ anywhere | miao! (喵!) on an exclamation, miao? on a question, miao-wu (喵呜) anywhere |
| Fires on | every line | 8 lines in 10 (Light), 19 in 20 (Full) |
| Never | a na right after a verb, as in iku na (行くな, "don't go") | a line with no Chinese characters |
The na row needs care. Iku na (行くな) means "don't go". Turn that na into nya and you get iku nya (行くにゃ), which sounds like "I'm going". So the algorithm checks what's before the na, and leaves it alone after a verb. The same guard sits in the inside-the-word table too, because testing found a back door there. The no → nyo swap (の → にょ) was in the table at first and got cut after a corpus test: it hit every kono and sono ("this" and "that") and every question ending in no, and sounded like a lisp, not a cat.
On Full, a line can also open with an interjection. Nya! only fires on a sentence ending in an exclamation mark, nya? only on a question. Each has a fire rate and a budget, so a line gets at most two insertions and three sound swaps, and the same interjection never comes twice in a row.
The safety check
Shy only adds words, so it can't change what you meant. Cat speech changes words, so every line is checked.
Every edit carries its own undo. "ne became nya" is stored with "nya was ne". Before the line is sent, the engine undoes all its edits on its own output and compares with what you said, character by character. If they match, the cat line goes to the voice. If anything is off, there's a bug in the table, so your original words go instead and the bad row shows up in my dashboard. That check is why I'm fine shipping the tables as data I can fix without a release.
Why an algorithm
I tested the AI route before building this, and here's why I didn't go with it.
- Privacy. Keeping sensitive conversations private is a critical part of how I built GenderShift. I want as little of what you say going to as few places as possible, and I don't want any big AI service receiving your conversational data. Your words already pass through speech to text and text to speech. A language model reading every line would be a third place, and one built to analyze what you say.
- Cost. The algorithm is free. An extra language model costs money on every line, and that would end up in the price.
- Speed. Nearly every line is made after you let go of the talk key, so anything before the voice adds to the wait. The fastest model I tried took about half a second per line, the others longer, sometimes over two seconds. The algorithm takes under a thousandth of a second.
- Your words. The models changed what was said in up to 4 lines out of 100. A small word added, or the end cut off. The algorithm changed nothing in over a thousand lines.
- The level. Asked for "a little", the models still touched every line, and one opened 8 in 10 with the same "Um". Nobody shy talks like that. The memory in the algorithm is there to stop it.
- Where it works. The big AI services don't work in some countries, including Russia and mainland China. The algorithm works everywhere.
Where it runs
Both run on your PC, between speech to text and text to speech. Nothing extra is sent anywhere. Shy also works on what you type in Type mode. Cat speech is for what you say out loud; when you type, write the nya yourself. Saved Lines are always said exactly as written.
If a line ever comes out wrong, tell me through Feedback in the app. Most of it is one line in a table, so a fix is quick, and the check means a bad row never changes what you said.