-
Notifications
You must be signed in to change notification settings - Fork 0
/
tts.m
54 lines (53 loc) · 1.48 KB
/
tts.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
function tts( text )
% This function converts text into speech.
% You can enter any form of text (less than 512 characters per line) into
% this function and it speaks it all.
%
% Note: Requires .NET
%
% Input:
% * text ... text to be spoken (character array, or cell array of characters)
%
% Output:
% * spoken text
%
% Example:
% Casual chat.
% Speak({'Hello. How are you?','It is nice to speak to you.','regards SAPI.'})
%
% Emphasising, silence, pitching, ... can be done (see external links)
%
% TODO: allow the above mentioned changes in voice
%
% See also: initSpeech, unloadSpeechLibrary
%
% External
% Microsoft's TTS Namespace
% http://msdn.microsoft.com/en-us/library/system.speech.synthesis.ttsengine(v=vs.85).aspx
% Microsoft's Synthesizer Class
% http://msdn.microsoft.com/en-us/library/system.speech.synthesis.speechsynthesizer(v=vs.85).aspx
%
%% Signature
% Author: W.Garn
% E-Mail: wgarn@yahoo.com
% Date: 2011/01/25 12:20:00
%
% Copyright 2011 W.Garn
%
if nargin<1
text ='English-Pronunciation.txt';
end
try
NET.addAssembly('System.Speech');
Speaker = System.Speech.Synthesis.SpeechSynthesizer;
if ~isa(text,'cell')
text = {text};
end
for k=1:length(text)
Speaker.Speak (text{k});
end
catch
warning(['If this is not a Windows system or ' ...
'the .Net class exists you will not be able to use this function.' ...
'Please let me know what went wrong: wgarn@yahoo.com']);
end