How text can be converted to speech form?

1 vue (au cours des 30 derniers jours)
Anuradha  Singh
Anuradha Singh le 20 Fév 2013
please tell me how to proceed..

Réponses (1)

Image Analyst
Image Analyst le 8 Fév 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) )

Catégories

En savoir plus sur Get Started with MATLAB dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by