open_jtalk_elixir
View SourceJapanese 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"}
]
endThen 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
| Function | Purpose |
|---|---|
OpenJTalk.say/2 | Synthesize and play speech |
OpenJTalk.to_wav_binary/2 | Return synthesized RIFF/WAV bytes |
OpenJTalk.to_wav_file/2 | Write synthesized speech to a WAV file |
OpenJTalk.play_wav_binary/2 | Play existing WAV data |
OpenJTalk.play_wav_file/2 | Play an existing WAV file |
OpenJTalk.Wav.concat_binaries/1 | Concatenate compatible WAV binaries |
OpenJTalk.Wav.concat_files/1 | Concatenate 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)| Option | Meaning | Default |
|---|---|---|
:rate | Speaking speed, clamped to 0.5..2.0 | 1.0 |
:pitch_shift | Semitone shift, clamped to -24..24 | 0 |
:timbre | Voice-color offset, clamped to -0.8..0.8 | 0.0 |
:gain | Output gain in dB, clamped to -20..20 | 0 |
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
| Build | CI coverage |
|---|---|
| Linux x86_64 | Host build and tests |
| Linux aarch64 | Host build and tests |
| macOS 14 arm64 | Host build and tests |
| Nerves RPi 4 aarch64 | Cross-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
- HexDocs API reference
OpenJTalkmodule documentation- Building and development
- Using with Nerves
- Architecture Decision Records
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:
- Open JTalk 1.11 - Modified BSD
- HTS Engine API 1.10 - Modified BSD
- MeCab 0.996 - GPL, LGPL, or BSD; used under the BSD terms
- Open JTalk Dictionary 1.11
- BSD-style license by NAIST
- HTS Voice "Mei"
- CC BY 3.0; "HTS Voice 'Mei' © Nagoya Institute of Technology, licensed CC BY 3.0."