espeak_sys/
lib.rs

1//Copyright (C) 2015  Chandler Atchley
2
3//This program is free software: you can redistribute it and/or modify
4//it under the terms of the GNU General Public License as published by
5//the Free Software Foundation, either version 3 of the License, or
6//(at your option) any later version.
7
8//This program is distributed in the hope that it will be useful,
9//but WITHOUT ANY WARRANTY; without even the implied warranty of
10//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11//GNU General Public License for more details.
12
13//You should have received a copy of the GNU General Public License
14//along with this program.  If not, see <http://www.gnu.org/licenses/>.
15
16#![allow(non_upper_case_globals)]
17#![allow(non_camel_case_types)]
18extern crate libc;
19
20use libc::{c_int, c_char, c_uchar, c_void, c_short, size_t, c_uint, wchar_t, FILE};
21
22pub const espeakRATE_MINIMUM: c_int = 80;
23pub const espeakRATE_MAXIMUM: c_int = 450;
24pub const espeakRATE_NORMAL:  c_int = 175;
25
26pub const espeakINITIALIZE_PHONEME_EVENTS: c_int = 0x0001;
27pub const espeakINITIALIZE_PHONEME_IPA:    c_int = 0x0002;
28pub const espeakINITIALIZE_DONT_EXIT:      c_int = 0x8000;
29
30pub const espeakCHARS_AUTO:  c_uint = 0;
31pub const espeakCHARS_UTF8:  c_uint = 1;
32pub const espeakCHARS_8BIT:  c_uint = 2;
33pub const espeakCHARS_WCHAR: c_uint = 3;
34pub const espeakCHARS_16BIT: c_uint = 4;
35
36pub const espeakSSML: c_uint = 0x10;
37pub const espeakPHONEMES: c_uint = 0x100;
38pub const espeakENDPAUSE: c_uint = 0x1000;
39pub const espeakKEEP_NAMEDATA: c_uint = 0x2000;
40
41#[repr(C)]
42pub enum espeak_EVENT_TYPE {
43	espeakEVENT_LIST_TERMINATED = 0,
44	espeakEVENT_WORD,
45	espeakEVENT_SENTENCE,
46	espeakEVENT_MARK,
47	espeakEVENT_PLAY,
48	espeakEVENT_END,
49	espeakEVENT_MSG_TERMINATED,
50	espeakEVENT_PHONEME,
51	espeakEVENT_SAMPLERATE
52}
53
54#[repr(C)]
55pub struct espeak_EVENT {
56	pub event_type: espeak_EVENT_TYPE,
57	pub text_position: c_int,
58	pub length: c_int,
59	pub audio_position: c_int,
60	pub sample: c_int,
61	pub user_data: *mut c_void,
62	pub id: u64
63}
64
65#[repr(C)]
66pub enum espeak_POSITION_TYPE {
67	POS_CHARACTER = 1,
68	POS_WORD,
69	POS_SENTENCE
70}
71
72#[repr(C)]
73pub enum espeak_AUDIO_OUTPUT {
74	AUDIO_OUTPUT_PLAYBACK,
75	AUDIO_OUTPUT_RETRIEVAL,
76	AUDIO_OUTPUT_SYNCHRONOUS,
77	AUDIO_OUTPUT_SYNCH_PLAYBACK
78}
79
80#[repr(C)]
81pub enum espeak_ERROR {
82	EE_OK = 0,
83	EE_INTERNAL_ERROR = -1,
84	EE_BUFFER_FULL = 1,
85	EE_NOT_FOUND = 2
86}
87
88#[repr(C)]
89pub enum espeak_PARAMETER {
90	espeakSILENCE = 0,
91	espeakRATE,
92	espeakVOLUME,
93	espeakPITCH,
94	espeakRANGE,
95	espeakPUNCTUATION,
96	espeakCAPITALS,
97	espeakWORDGAP,
98	espeakOPTIONS,
99	espeakINTONATION,
100	espeakRESERVED1,
101	espeakRESERVED2,
102	espeakEMPHASIS,
103	espeakVOICETYPE,
104	N_SPEECH_PARAM
105}
106
107#[repr(C)]
108pub enum espeak_PUNCT_TYPE {
109	espeakPUNCT_NONE = 0,
110	espeakPUNCT_ALL = 1,
111	espeakPUNCT_SOME = 2
112}
113
114#[repr(C)]
115pub struct espeak_VOICE {
116	pub name: *const c_char,
117	pub languages: *const c_char,
118	pub identifier: *const c_char,
119	pub gender: c_uchar,
120	pub age: c_uchar,
121	pub variant: c_uchar,
122	xx1: c_uchar,
123	score: c_int,
124	spare: *mut c_void
125}
126
127pub type t_espeak_callback = extern "C" fn(*mut c_short, c_int, *mut espeak_EVENT) -> c_int;
128
129#[link(name = "espeak")]
130extern "C" {
131	pub fn espeak_Initialize(output: espeak_AUDIO_OUTPUT, buflength: c_int, path: *const c_char, options: c_int) -> c_int;
132	pub fn espeak_SetSynthCallback(SynthCallback: t_espeak_callback);
133	pub fn espeak_SetUriCallback(UriCallback: extern fn(c_int, *const c_char, *const c_char) -> c_int);
134	pub fn espeak_Synth(text: *const c_void,
135		size: size_t,
136		position: c_uint,
137		position_type: espeak_POSITION_TYPE,
138		end_position: c_uint,
139		flags: c_uint,
140		unique_identifier: *mut c_uint,
141		user_data: *mut c_void) -> espeak_ERROR;
142	pub fn espeak_Synth_Mark(text: *const c_void,
143		size: size_t,
144		index_mark: *const c_char,
145		end_position: c_uint,
146		flags: c_uint,
147		unique_identifier: *mut c_uint,
148		user_data: *mut c_void) -> espeak_ERROR;
149	pub fn espeak_Key(key_name: *const c_char) -> espeak_ERROR;
150	pub fn espeak_Char(character: wchar_t) -> espeak_ERROR;
151	pub fn espeak_SetParameter(parameter: espeak_PARAMETER, value: c_int, relative: c_int) -> espeak_ERROR;
152	pub fn espeak_GetParameter(parameter: espeak_PARAMETER, current: c_int) -> c_int;
153	pub fn espeak_SetPunctuationList(punctlist: *const wchar_t) -> espeak_ERROR;
154	pub fn espeak_SetPhonemeTrace(value: c_int, stream: *mut FILE);
155	pub fn espeak_TextToPhonemes(textptr: *const *const c_void, textmode: c_int, phonememode: c_int) -> *const c_char;
156	pub fn espeak_CompileDictionary(path: *const c_char, log: *mut FILE, flags: c_int);
157	pub fn espeak_ListVoices(voice_spec: *mut espeak_VOICE) -> *const *const espeak_VOICE;
158	pub fn espeak_SetVoiceByName(name: *const c_char) -> espeak_ERROR;
159	pub fn espeak_SetVoiceByProperties(voice_spec: *mut espeak_VOICE) -> espeak_ERROR;
160	pub fn espeak_GetCurrentVoice() -> *mut espeak_VOICE;
161	pub fn espeak_Cancel() -> espeak_ERROR;
162	pub fn espeak_IsPlaying() -> c_int;
163	pub fn espeak_Synchronize() -> espeak_ERROR;
164	pub fn espeak_Terminate() -> espeak_ERROR;
165	pub fn espeak_Info(path_data: *const *const c_char) -> *const c_char;
166}