C语言制作的讯飞语音合成、识别、唤醒标准调用接口DLL

一 、导出函数:

LIBRARY “XF_MSC”
EXPORTS
addxy @1 //测试用的两数和函数
mystrcat @2 //测试用的两字符串连接函数
tts @3 //讯飞文本合成语音函数,祥见原型说明
autotxt @4 //讯飞实时语音识别函数,祥见原型说明
wavtotxt @5 //讯飞语音文件识别成文本函数,祥见原型说明
micWAKEUP @6 //讯飞语音唤醒函数,祥见原型说明

二、/讯飞文本合成语音/

函数原型:

int tts(const char userid, const char text, const char filename, const char params)

参数说明:

1、userid: 讯飞创建的APPID:

C语言制作的讯飞语音合成、识别、唤醒标准调用接口DLL

2、text:要合成的文本内容,短文本不超过1024字节

3、filename :合成后保存的语音文件。

4、params: 参数串:

“voice_name = xiaoyan, text_encoding = gb2312, sample_rate = 16000, speed = 50, volume = 50, pitch = 50, rdn = 2”

更多信息,请参考iFLYTEK云平台文档。

[En]

For more information, please see iFLYTEK Cloud platform documentation.

VFP调用示例:

Declare INTEGER tts IN “XF_MSC.DLL” string @a1,string @b1,string @c1,string @d1
xiaoyan小燕,aisjiuxu许久,aisxping小萍,aisjinger小倩,aisbabyxu许小宝, *
x2_yezi小路,x2_qianxue千雪-情感,x_yuer玉儿,x_mengchun小春,x_xiaonuo_novel小瑞,x_mengmenghappy萌萌高兴,x_mengmengneutral萌萌中立
x_mengmengsad萌萌悲伤,x_xiaoqiao小乔,x2_xiaoyue小月粤语,x_xiaoyan晓燕,x_xiaoru小茹,x2_xiaoshi_cts小师
asktxt1=”小蛋黄,我爱你。”
cshu=”voice_name = xiaoyan, text_encoding = gb2312, sample_rate = 16000, speed = 50, volume = 50, pitch = 50, rdn = 2″
IF tts(“b12de7e8″,asktxt1,asktxt1+”.wav”,cshu)=0
playwav(asktxt1+”.wav”)
ENDIF

返回值,成功返回0,不成功返回负值,具体含意如下:

-1:注册错误。请检查APPID

-2:params is error,参数串错误

-3:生成语音文件错误,可能是同名文件正在使用。

-4:QTTSSessionBegin failed

-5:”QTTSTextPut failed

-6:QTTSAudioGet failed

-7:QTTSSessionEnd failed

三、实时短语音识别。

函数原型:

char autotxt(const char userid, const char* session_begin_params, int upload_on)

参数说明:

1、userid:同上 tts 函数

2、session_begin_params:参数串,形如:

“sub = iat, domain = iat, language = zh_cn, accent = mandarin, sample_rate = 16000, result_type = plain, result_encoding = gb2312”;

更多信息请参见飞云平台文档。

[En]

For more information, see the Feiyun platform documentation.

3、upload_on:是否上传用户词表,0:不上传,1:上传,选择1时当前目录需要有userwords.txt 文件,文件内容形如:{“userword”:[{“words”:[“中美速控”,”人民”,”张山”,”明百”,”可勒”],”name”:”再见”},{“words”:[“邯郸钢铁”,”电话簿”],”name”:”常用命令”},{“words”:[“身体健康”,”恭喜发财”,”吉祥如意”,”龙年”],”name”:”新年短信”}]}

返回值:如果成功,则返回识别的字符串。如果失败,则返回以100:开头的错误消息字符串。

[En]

Return value: if successful, the recognized string is returned. If it fails, an error message string starting with 100: is returned.

四、短语音文件转文本

函数原型:

char wavtotxt(const char userid, const char session_begin_params, int upload_on, const char audio_file)

参数说明,userid/session_begin_params/upload_on同上

audio_file:语音文件,WAV格式,PCM、等

五、关键词唤醒

函数原型:char micWAKEUP(const char userid, const char* session_begin_params)

参数说明:userid 同上。

char* session_begin_params:参数串

形如:”ivw_threshold=0:1450,sst=wakeup,ivw_res_path =fo|res/ivw/wakeupresource.jet”

其中”res/ivw/wakeupresource.jet”为唤醒关键词表文件相对路径,这个文件在设置唤醒词后下载SDK文档时包含了。

Original: https://blog.csdn.net/xycwr/article/details/122758719
Author: 昕宇
Title: C语言制作的讯飞语音合成、识别、唤醒标准调用接口DLL

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/498186/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

亲爱的 Coder【最近整理,可免费获取】👉 最新必读书单  | 👏 面试题下载  | 🌎 免费的AI知识星球