1 /* 2 * Copyright (C) 2015-2020 Alibaba Group Holding Limited 3 */ 4 5 #ifndef __UVOICE_TTS_H__ 6 #define __UVOICE_TTS_H__ 7 8 #include "uvoice_types.h" 9 10 typedef enum { 11 TTS_AICLOUD_ALIYUN = 0, /* aliyun tts service */ 12 /*if use aliyun tts service, please get app_key、token from aliyun,see https://help.aliyun.com/document_detail/84435.html?spm=a2c4g.11186623.2.30.355b5275kgR9PT 13 to get the config guide*/ 14 } tts_aicloud_type_e; 15 16 typedef enum { 17 TTS_ENCODE_GBK = 0, 18 TTS_ENCODE_UTF8, 19 } tts_encode_type_e; 20 21 typedef struct { 22 char *app_key; /* get it form the cloud service */ 23 char *token; /* get it form the cloud service */ 24 media_format_t format; /* tts output format, now only support wav, pcm, mp3 */ 25 int sample_rate; /* support 8000Hz、16000Hz */ 26 char *voice; /* voice people */ 27 int volume; /* 0 ~ 100 */ 28 int speech_rate; /* -500 ~ 500 */ 29 int pitch_rate; /* -500 ~ 500 */ 30 tts_encode_type_e text_encode_type; 31 } tts_config_t; 32 33 typedef enum 34 { 35 TTS_RECV_URL = 0, 36 TTS_RECV_DATA = 1, 37 } tts_recv_type_e; 38 39 typedef enum 40 { 41 TTS_TRANS_START = 0, 42 TTS_TRANS_COMPLETE = 1, 43 TTS_RECV_START = 2, 44 TTS_RECV_COMPLETE = 3, 45 TTS_INFO = 4, 46 TTS_WARNING = 5, 47 TTS_ERROR = 6, 48 } tts_event_e; 49 50 typedef struct { 51 int (*recv_url)(char *tts_url); 52 int (*recv_data)(uint8_t *buffer, int nbytes, int index); 53 int (*event)(tts_event_e event, char *info); 54 } tts_recv_callback_t; 55 56 typedef struct { 57 int (*tts_init)(tts_aicloud_type_e aicloud_type, tts_config_t *config); 58 int (*tts_request)(char *text, tts_recv_type_e recv_type, tts_recv_callback_t *recv_cb); 59 int (*tts_stop)(); 60 void *priv; 61 } uvoice_tts_t; 62 63 #ifdef UVOICE_TTS_ENABLE 64 uvoice_tts_t *uvoice_tts_create(void); 65 int uvoice_tts_release(uvoice_tts_t *uvoice_tts); 66 #endif 67 68 #endif /* __UVOICE_TTS_H__ */ 69