Text to Speech using the Narakeet Command-line Tool

The Narakeet command line tool (CLI) is the easiest way to automate text to speech conversion from a command line using Narakeet’s rich voice and language library, or integrate Narakeet into custom build tools. This page explains how you can use the Narakeet CLI to quickly build audio files from scripts.

Installing and setting up the Narakeet CLI

For general information on installing and setting up the Narakeet command line tool, check out Using the Narakeet Command-line Tool.

Creating audio files using Narakeet CLI

By default, the Narakeet CLI creates video files. The video workflows support more features but they are slower than straight text-to-speech conversion. If you just need the audio, then running an audio workflow will be significantly faster. To select an audio project type, provide the following arguments:

--project-type audio

This selects an audio workflow.

Selecting the output type

Narakeet CLI supports 3 output types for audio files:

  • m4a: (default) compressed MPEG-4 audio container files with AAC encoding, a great balance between file size and quality
  • mp3: compressed MP3 file. Supported by more players than m4a, but worse quality
  • wav: uncompressed 16-bit PCM files. Highest quality but also largest file size.

You can select the output type using the --output-type parameter.

Creating simple audio files

For simple scripts (that fit into a command line), use the --script argument and provide the text directly. Here are some examples:

Build an audio WAV from text, saving to result.wav:

narakeet-api-client --api-key $API_KEY \
 --project-type audio \
 --script "Hi there" \
 --output-type wav

Build an audio WAV from text, using voice Brian, saving to result.wav:

narakeet-api-client --api-key $API_KEY \
 --project-type audio \
 --script "Hi there" \
 --output-type wav \
 --voice brian

Build an audio WAV from text, using voice Brian, saving to brian.wav:

narakeet-api-client --api-key $API_KEY \
 --project-type audio \
 --script "Hi there" \
 --output-type wav \
 --voice brian \
 --output brian.wav

Building from text files

For more complex scripts (multiple lines, longer text, or when you want to use script header configuration or stage directions), you can save the script into a plain text file (UTF8 encoding) and pass the file name using the --script-file argument. Here are some examples:

Build an audio MP3 from a local text file, saving to result.mp3:

narakeet-api-client --api-key $API_KEY \
 --project-type audio \
 --script-file script.txt \
 --output-type mp3

Build an audio WAV from a local text file, using the Rodney voice, saving to my-script.wav

narakeet-api-client --api-key $API_KEY \
 --project-type audio \
 --script-file script.txt \
 --output-type wav \
 --voice rodney \
 --output my-script.wav

Selecting the default voice

You can select the default voice either using the --voice parameter from the command line, or by supplying the voice header in your script.

All our Text to Speech voices are supported through the CLI.

Configuring other options (voice speed/volume…)

Narakeet scripts support setting default options in a header section (enclosed in --- above and below, at the start of the script file). You can use the header section to set the default voice speed, volume, choose a voice and a lot more. For more information, check out the Script header formatting reference.

---
voice: Brian
voice-volume: loud
---

This script will be read by Brian, loudly

More information