Module: Flite

Defined in:
lib/flite.rb,
lib/flite/version.rb,
ext/flite/rbflite.c

Defined Under Namespace

Classes: Error, RuntimeError, Voice

Constant Summary collapse

VERSION =
"0.1.1"
CMU_FLITE_VERSION =
cmu_flite_version
@@default_voice =
Flite::Voice.new

Class Method Summary collapse

Class Method Details

.default_voiceFlite::Voice

Returns the voice used by String#speak and String#to_speech.

Returns:



45
46
47
# File 'lib/flite.rb', line 45

def self.default_voice
  @@default_voice
end

.default_voice=(name) ⇒ Object

Set the voice used by String#speak and String#to_speech. When name is a Voice, use it. Otherwise, use a new voice created by Flite::Voice.new(name).

Parameters:

See Also:



55
56
57
58
59
60
61
# File 'lib/flite.rb', line 55

def self.default_voice=(name)
  if name.is_a? Flite::Voice
    @@default_voice = name
  else
    @@default_voice = Flite::Voice.new(name)
  end
end

.list_builtin_voicesArray

Returns builtin voice names.

Examples:

Flite.list_builtin_voices # => ["kal", "awb_time", "kal16", "awb", "rms", "slt"]

Returns:

  • (Array)


253
254
255
256
257
258
259
260
261
262
263
264
265
# File 'ext/flite/rbflite.c', line 253

static VALUE
flite_s_list_builtin_voices(VALUE klass)
{
    VALUE ary = rb_ary_new();
    const rbflite_builtin_voice_t *builtin = rbflite_builtin_voice_list;

    while (builtin->name != NULL) {
        rb_ary_push(ary, rb_usascii_str_new_cstr(builtin->name));
        builtin++;
    }

    return ary;
}

.sleep_time_after_speaking=(sec) ⇒ Object

Sets sleep time after Flite::Voice#speak. The default value is 0 on Unix and 0.3 on Windows.

This is workaround for voice cutoff on Windows. The following code speaks “Hello Wor.. Hello World” without 0.3 seconds sleep.

"Hello World".speak # The last 0.3 seconds are cut off by the next speech on Windows.
"Hello World".speak

Parameters:

  • sec (Float)

    seconds to sleep



307
308
309
310
311
312
# File 'ext/flite/rbflite.c', line 307

static VALUE
flite_s_set_sleep_time_after_speaking(VALUE klass, VALUE val)
{
    sleep_time_after_speaking = rb_time_interval(val);
    return val;
}

.supported_audio_typesArray

Returns supported audio types used as the second argument of Flite::Voice#to_speech.

Examples:

# Compiled with mp3 support
Flite.supported_audio_types # => [:wav, :raw, :mp3]

# Compiled without mp3 support
Flite.supported_audio_types # => [:wav, :raw]

Returns:

  • (Array)


279
280
281
282
283
284
285
286
287
288
289
290
# File 'ext/flite/rbflite.c', line 279

static VALUE
flite_s_supported_audio_types(VALUE klass)
{
    VALUE ary = rb_ary_new();

    rb_ary_push(ary, sym_wav);
    rb_ary_push(ary, sym_raw);
#ifdef HAVE_MP3LAME
    rb_ary_push(ary, sym_mp3);
#endif
    return ary;
}