open_jtalk_elixir

View Source

Hex version CI

Run in Livebook

Japanese text-to-speech for Elixir, powered by Open JTalk.

OpenJTalk.say("こんにちは")

Why this package?

  • A small Elixir API for speech playback and WAV generation
  • Automatic native builds with pinned, verified Open JTalk dependencies
  • Support for Linux, macOS, and Nerves

Installation

Add open_jtalk_elixir to your dependencies:

def deps do
  [
    {:open_jtalk_elixir, "~> 0.4"}
  ]
end

Then fetch dependencies and compile:

mix deps.get
mix compile

The first compile builds the required native components and may download verified source and runtime assets. See Building for system requirements and the complete build flow.

Quick start

Speak text through an available system audio player:

:ok = OpenJTalk.say("こんにちは")

Generate WAV data in memory:

{:ok, wav} = OpenJTalk.to_wav_binary("こんにちは")

Write a WAV file:

{:ok, path} = OpenJTalk.to_wav_file("こんにちは", out: "/tmp/greeting.wav")

say/2 uses aplay, paplay, afplay, or SoX play, depending on what is available on the system.

Main API

FunctionPurpose
OpenJTalk.say/2Synthesize and play speech
OpenJTalk.to_wav_binary/2Return synthesized RIFF/WAV bytes
OpenJTalk.to_wav_file/2Write synthesized speech to a WAV file
OpenJTalk.play_wav_binary/2Play existing WAV data
OpenJTalk.play_wav_file/2Play an existing WAV file
OpenJTalk.Wav.concat_binaries/1Concatenate compatible WAV binaries
OpenJTalk.Wav.concat_files/1Concatenate compatible WAV files

Compatible WAV data can be joined without re-encoding:

{:ok, a} = OpenJTalk.to_wav_binary("一つ目")
{:ok, b} = OpenJTalk.to_wav_binary("二つ目")
{:ok, merged} = OpenJTalk.Wav.concat_binaries([a, b])

Common options

OpenJTalk.say("こんにちは", rate: 1.1, pitch_shift: 2, gain: 1)
OptionMeaningDefault
:rateSpeaking speed, clamped to 0.5..2.01.0
:pitch_shiftSemitone shift, clamped to -24..240
:timbreVoice-color offset, clamped to -0.8..0.80.0
:gainOutput gain in dB, clamped to -20..200

See the OpenJTalk module documentation for all options, asset-resolution rules, and runtime errors.

Nerves

Nerves is a supported build path. In common cases, add the dependency and compile normally for the selected MIX_TARGET.

The bundled dictionary is about 103 MB uncompressed, so firmware size deserves an explicit decision. See Using with Nerves for build behavior, audio requirements, and external asset configuration.

Supported platforms and requirements

BuildCI coverage
Linux x86_64Host build and tests
Linux aarch64Host build and tests
macOS 14 arm64Host build and tests
Nerves RPi 4 aarch64Cross-compilation

The project supports Elixir 1.15 and later. Native compilation requires a C/C++ toolchain, make, curl, tar, and unzip. A Hex installation normally needs outbound HTTPS access during its first build. See Building for details.

Documentation

License

open_jtalk_elixir is released under the Apache License 2.0.

The Hex package does not contain the upstream source or asset archives, but a build may download these pinned third-party components: