MATLAB Answers

How do I create and save an audio file from the output of text to speech synthesizer

4 ビュー (過去 30 日間)
Gwood 2021 年 6 月 19 日
コメント済み: Gwood 2021 年 6 月 23 日
How do I save an audio file generated by the text to speech synthesizer, for instance using the code given below. My aim is to take the synthesizer audio output and continue processing it. % Program to do text to speech. % 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. %**% NET.addAssembly('System.Speech'); obj = System.Speech.Synthesis.SpeechSynthesizer; obj.Volume = 100; Speak(obj, caUserInput);


Jan 2021 年 6 月 21 日
編集済み: Jan 2021 年 6 月 23 日
synth = System.Speech.Synthesis.SpeechSynthesizer;
synth.Volume = 100;
synth.SetOutputToWaveFile(fullfile(tempdir, 'yourFile.wav')); % [EDITED, typo]
Speak(synth, 'Hello world');
synth.SetOutputToNull; % [EDITED] Close the file
  3 件のコメント
Gwood 2021 年 6 月 23 日
Thank you! Worked fine


その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by