酥脆可口的萝莉音来了~~~

  • 2019 年 10 月 29 日
  • 笔记

今天换个口味,给大家介绍一个好玩的东西 —— tts语音合成。matlab自身不带相关语音合成函数,这里需要使用微软自带SpVoice,通过创建com对象,调用SpVoice语音合成方法来实现发生功能,可以通过文字内容自动选择中文发音或者英文发音。

为了方便文本输入,使用uicontrol函数创建了操作界面,由于能力有限,可惜没有能够实现暂停和继续功能,要是有懂的小伙伴,欢迎给小编留言。

(程序运行后界面)

clc;clear;close all;  % 创建COM.SAPI_SpVoice对象  vCom = actxserver('SAPI.SpVoice');  %% 创建界面  scr = get(groot,'ScreenSize');  pict=figure('position',[scr(3)/2-200,scr(4)/2-300, 500,450],'name','matlab爱好者公众号倾情推出 (ID:matlabaihaozhe)','NumberTitle','off','menubar','none','toolbar','none',...      'Resize','off');  text01=uicontrol(pict,'style','text','position',[0 435 500 10],'string','******************************************************************************************','FontSize',10,'ForegroundColor','b');  text02=uicontrol(pict,'style','text','position',[95 395 320 40],'string','文本阅读器','FontSize',20,'ForegroundColor','r');  text03=uicontrol(pict,'style','text','position',[0 392 500 10],'string','******************************************************************************************','FontSize',10,'ForegroundColor','b');  text1 = uicontrol(pict,'style','text','position',[85 355 330 30],'string','~~~请在下方输入文字,点击阅读~~~','FontSize',12,'ForegroundColor','k');  con = uicontrol(pict,'style','edit','position',[25 57 450 300],'string','喜欢、爱好、想学matlab编程,关注matlab爱好者是您不错的选择!还没关注,还没关注,还没关注,赶快关注!','FontSize',15,'ForegroundColor','r','max',inf,'HorizontalAlignment','left');    %% 执行程序  sV = uicontrol(pict,'style','text','position',[20 18 120 30],'string','','FontSize',14,'ForegroundColor','b');  volC = uicontrol(pict,'Style','slider','position',[145 20 100 30],'string','','CallBack','showVolume(volC,sV);');  volC.Min = 0;  volC.Max = 100;  volC.Value = 50;  showVolume(volC,sV);  uicontrol(pict,'style','pushbutton','position',[260 20 100 30],'string','阅读','FontSize',14,'ForegroundColor','b','CallBack',...      'speakText(con,vCom,volC);');  uicontrol(pict,'style','pushbutton','position',[380 20 100 30],'string','退出','FontSize',14,'ForegroundColor','r','CallBack','delete(vCom); clear vCom; delete(pict);close();');

这个声音好听吗?哈哈哈~~~

,要是觉得不好听,就在下方狂喷小编吧!在公众号中回复“文本阅读”即可获取所有相关文件,还等什么,赶紧回复获取吧!

参考资料:

[1] https://blog.csdn.net/weixin_34162401/article/details/85481046

[2] http://blog.sina.com.cn/s/blog_54be98b80102v5yw.html

[3] https://blog.csdn.net/u014646950/article/details/54933955

封面图片:由GraphicMama-team在Pixabay上发布