Matlab Text Dosyasını Seslendiren Program(windows x86 speech api)

Aslında internette bu apiyle yapılmış çok uygulama görmüşsünüzdür ama ben ingilizce yazılmış bir dosyayı okuması için tekrardan ayarladım. Çok basit versiyonunu yayınlıyorum. Üretilen sesi işlemek üzere değişkene attığım bir versiyonda elimde var ama artık o versiyon bana kalsın.
Umarım bir fikir verir.

<ttsbasic.m>
function ttsbasic(String)
%UNTİTLED9 Summary of this function goes here
%   Detailed explanation goes here
defaultString = 'Hello World!  MATLAB is an awesome program!';
if nargin<1
    String=defaultString;
end

if isempty(String)
return;
end % Bail out if they clicked Cancel.
caUserInput = char(String); % Convert from cell to string.
NET.addAssembly('System.Speech');
obj = System.Speech.Synthesis.SpeechSynthesizer;
obj.Volume = 100;
Speak(obj, caUserInput);
end
</ttsbasic.m>

Apply.m ile fonksiyonun ugulamasını yaptım. tam dosya adını yazın ve size ingilizce olarak okusun. her satırda gecikme eklenmiş.
<Apply.m>
fileID = fopen('tam dosya adı', 'rt');
% Read the first line of the file.
textLine = fgetl(fileID);
while ischar(textLine)
    ttsbasic(textLine);
    fprintf('%s\n', textLine);
    textLine = fgetl(fileID);
end
% All done reading all lines, so close the file.
fclose(fileID);
</Apply.m>

Yorumlar

Popüler Yayınlar