MATLAB Answers

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

4 ビュー (過去 30 日間)
Gwood
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. %*https://www.mathworks.com/matlabcentral/answers/159113-text-to-speech-synthesis-matlab-code#answer_155653*% NET.addAssembly('System.Speech'); obj = System.Speech.Synthesis.SpeechSynthesizer; obj.Volume = 100; Speak(obj, caUserInput);

採用された回答

Jan
Jan 2021 年 6 月 21 日
編集済み: Jan 2021 年 6 月 23 日
And:
NET.addAssembly('System.Speech');
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
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