How text can be converted to speech form?

1 visualización (últimos 30 días)
Anuradha  Singh
Anuradha Singh el 20 de Feb. de 2013
Respondida: Image Analyst el 8 de Feb. de 2024
please tell me how to proceed..

Respuestas (1)

Image Analyst
Image Analyst el 8 de Feb. de 2024
% 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) )

Categorías

Más información sobre Get Started with MATLAB en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by