rsc3/doc-schelp/HelpSource/Classes/Speech.schelp

105 lines
3.3 KiB
Text

class:: Speech
summary:: [DEPRECATED] lets you use the Apple speech synthesizer
categories:: Platform>macOS (OS X)
description::
warning::
Speech has been deprecated for a number of reasons:
list::
## The audio output is independent of the server, so it has major limitations when attempting to use it in SC compositions.
## The core library should be small, and speech synthesis is too niche to merit inclusion.
## It is macOS only, and implementing cross-platform compatibility is nontrivial.
::
Generally, the replacement is to use unixCmd to invoke a speech synthesizer yourself. There is also a third-party quark that simplifies this for you: https://github.com/adcxyz/say.
::
code::
"hi i'm talking with the default voice now, i guess".speak;
::
Speech consists of an link::Classes/Array:: of SpeechChannels. By default Speech is initialized with only one channel, but can be set up to use up to 16 by providing an argument to init. Channels may be used through a SpeechChannel object or by setting the channel in Speech's methods (see examples below).
Speech is a function of the operating system and not the server. By consequence, strong::it is not possible to use UGens to filter or record the output directly::. You may be able to patch system output to system input (either by hardware of by software) to rout it to the server.
note::
Currently only supported on macOS. In SwingOSC there is the equivalent JSpeech.
::
ClassMethods::
private::prInitSpeech
Examples::
code::
Speech.init(2);
Speech.channels[0].speak("hallo");
Speech.channels[0].isActive;
Speech.channels[0].voice_(14);
Speech.channels[0].speak("hallo");
Speech.channels[0].pitch_(60);
Speech.channels[0].speak("hallo");
Speech.channels[0].volume_(-20.dbamp);
Speech.channels[0].pitchMod_(50);
Speech.channels[0].speak("hallo");
Speech.channels[0].stop(\immediate);
Speech.channels[0].stop(\endOfWord);
Speech.channels[0].stop(\endOfSentence);
::
Force the voice to speaking something different by setting the second argument of speak to true.
code::
Speech.channels[0].speak("Force the voice to speaking something different.");
Speech.channels[0].speak("Force the voice to speaking something different.".reverse, true);
::
First argument is always the voice channel number, second the value.
code::
Speech.setSpeechVoice(0,14);
Speech.setSpeechPitch(0, 40); //pitch in MIDI Num
Speech.setSpeechRate(0, 10);
Speech.setSpeechVolume(0,0.1);
Speech.setSpeechPitchMod(0, 200);
Speech.stop(0, 1);
::
Two actions can be applied:
code::
Speech.wordAction = {arg voiceNum;
//i.postln;
// the currently speaking text may not be changed
//Speech.setSpeechPitch(voiceNum,[41,60].choose);
//Speech.setSpeechRate(voiceNum,[60,80, 10].choose);
};
Speech.doneAction_({arg voiceNum;
Speech.setSpeechPitch(voiceNum,[41,48,40,43,30,60].choose);
});
::
Pause the speech while speaking: 1=pause, 0= start
code::
Speech.pause(0,1);
::
Initialization happens automatically, by default with one voice channel.
You may explicitly initialize with more channels, up to 16:
code::
(
Speech.init(16);
Task({
16.do ({arg i;
[0.1, 0.18, 0.2].choose.wait;
Speech.setSpeechRate(i,[90, 30, 60].choose);
Speech.setSpeechVolume(i,0.07);
"no this is private. float . boolean me. char[8] ".speak(i);
});
}).play;
)
//jan@sampleAndHold.org 04/2003
//update 10/2007
::