Dictation Mode#
Dictation mode enables you to use voice to type and format text.
When a dictation command is recognized during speech recognition, it is mapped to a corresponding punctuation, special character or formatting style. For example, the word “period” would appear on the transcript as “.”, “dollar sign” as “$” and “new line” as “[NEW_LINE]”.
Example#
We enable dictation mode by setting the enable_dictation
TranscriptionConfig
field to true
.
from soniox.transcribe_file import transcribe_file_short
from soniox.speech_service import SpeechClient
# Do not forget to set your API key in the SONIOX_API_KEY environment variable.
def main():
with SpeechClient() as client:
result = transcribe_file_short(
"../test_data/test_audio_dictation.mp3", client, enable_dictation=True
)
print(" ".join(w.text for w in result.words))
if __name__ == "__main__":
main()
Run
python3 dictation.py
Output
This is really cool . [NEW_LINE] I am going to voice type from now on . What about you ?
const { SpeechClient } = require("@soniox/soniox-node");
// Do not forget to set your API key in the SONIOX_API_KEY environment variable.
const speechClient = new SpeechClient();
(async function () {
const result = await speechClient.transcribeFileShort(
"../test_data/test_audio_dictation.mp3",
{
enable_dictation: true,
}
);
console.log(result.words.map((word) => word.text).join(" "));
})();
Run
node dictation.js
Output
This is really cool . [NEW_LINE] I am going to voice type from now on . What about you ?
Punctuations by Speech Recognition and Dictation#
When dictation mode is enabled, punctuations are recognized by both regular speech recognition and dictated commands. For example, if you say “Is that yours”, then the speech engine will recognize it as a question and automatically add “?”, resulting in transcription “Is that yours?”. At the same time, if you say “Is that yours question mark”, the resulting transcription will be “Is that yours?”
Supported Dictation Commands#
The list of supported dictation commands and their mappings are provided in the table below.
Dictation Command | Mapping |
---|---|
new line | [NEW_LINE] |
next line | [NEW_LINE] |
new paragraph | [NEW_PARAGRAPH] |
next paragraph | [NEW_PARAGRAPH] |
period | . |
question mark | ? |
exclamation mark | ! |
comma | , |
ampersand | & |
colon | : |
semicolon | ; |
begin quote | “ |
end quote | “ |
ellipsis | … |
dollar sign | $ |