How text can be converted to speech form?

2 次查看(过去 30 天)
please tell me how to proceed..

回答(1 个)

Image Analyst
Image Analyst 2024-2-8
% Program to do text to speech. Works only with Windows Operating System.
% Get user's sentence
userPrompt = 'What do you want the computer to say?';
titleBar = 'Text to Speech';
defaultString = 'Hello World! MATLAB is an awesome program!';
caUserInput = inputdlg(userPrompt, titleBar, 1, {defaultString});
if isempty(caUserInput)
return;
end % Bail out if they clicked Cancel.
caUserInput = char(caUserInput); % Convert from cell to string.
% Instantiate the .NET assembly that will to the talking.
NET.addAssembly('System.Speech');
obj = System.Speech.Synthesis.SpeechSynthesizer;
% voiceCollection = obj.GetInstalledVoices() % Get list of all voices installed on the system.
% methods(voiceCollection) % See what it can do.
% Set the volume.
obj.Volume = 100;
% Here is the line of code that actually does the talking:
Speak(obj, caUserInput);
%==========================================================================
% Below is the mac version, from Walter Roberson
% userPrompt = 'What do you want the computer to say?';
% titleBar = 'Text to Speech';
% defaultString = 'Hello World! MATLAB is an awesome program!';
% caUserInput = inputdlg(userPrompt, titleBar, 1, {defaultString});
% if isempty(caUserInput)
% return;
% end; % Bail out if they clicked Cancel.
% caUserInput = char(caUserInput); % Convert from cell to string.
%
% system( sprintf('say "%s"', caUserInput) )

类别

Help CenterFile Exchange 中查找有关 Get Started with MATLAB 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by