[SOLVED] Speech lines/voice acting for dynamically created texts

Started by cat, Tue 13/08/2019 20:59:46

Previous topic - Next topic

cat

Hi guys!

I'm a total noob regarding using voice acting in AGS. I used the search but didn't find anything.

In my code, I have a function that sets
Code: ags
currentText = "A lemon!";


Later, I will call
Code: ags
player.Say(currentText);


I get all those texts included in the translation file, but they are neither in the speechref.txt nor in VoiceSpeech.txt
Is it even possible what I want to do? Or should I just import those lines as normal sound and play it? I don't want to show the text anyway, just play the voice acting.

Cassiebsg

I haven't tried it, but have you tried to add the line number to the text?

as in
Code: ags
currentText = "&10 A lemon!";


You probably have to add the numbers manually though.
There are those who believe that life here began out there...

eri0o

Cat, I have no idea if this is useful or not, but since AGS 3.5.0, CW added the Game.PlayVoiceClip(Character*, int cue, bool as_speech ). Alternatively, if the String is constant from a possible alternatives, maybe refactoring for having if-else/switch cases with the different say functions for the sound be searchable by speech auto-numbering?

cat

Thanks for the suggestions!

Quote from: Cassiebsg on Tue 13/08/2019 22:02:06
Code: ags
currentText = "&10 A lemon!";

Good idea, I'll try that.

Quote from: eri0o on Tue 13/08/2019 23:40:13
Game.PlayVoiceClip(Character*, int cue, bool as_speech ).
Do you have documentation for this? I couldn't find it in the help file.

Quote
Alternatively, if the String is constant from a possible alternatives, maybe refactoring for having if-else/switch cases with the different say functions for the sound be searchable by speech auto-numbering?
Somewhat ugly, but a good idea as last resort.


In the end, I want to achieve that the audio is played blocking and can be skipped just as normal player.Say();

For now, I'll manually create the voice acting script from the translation file, since it's not a lot of text and there is only one voice actor.

Btw, how can I hide the text when there is a voice file available? I've seen this implemented for various games.


Vincent

Quote from: cat on Wed 14/08/2019 07:43:52
Btw, how can I hide the text when there is a voice file available? I've seen this implemented for various games.

Maybe you are referring to VoiceMode. Valid values for VoiceMode are:

eSpeechTextOnly      no voice, text only
eSpeechVoiceAndText  both voice and text
eSpeechVoiceOnly     voice only, no text

Code: ags

if (SubtitleEnabled) {Speech.VoiceMode = eSpeechVoiceAndText;}
else
{
   if (IsSpeechVoxAvailable() == 1) Speech.VoiceMode = eSpeechVoiceOnly;
}

cat


Vincent

Quote from: cat on Wed 14/08/2019 08:23:03
Thanks, Vincent!

You are welcome, I am interested to know how "Game.PlayVoiceClip(Character*, int cue, bool as_speech)" work. Though I don't like to use the new versions of Ags but still interested.

Crimson Wizard

#7
Game.PlayVoiceClip(Character*, int cue, bool as_speech) plays a voice clip from speech.vox in a non-blocking manner. It returns an AudioChannel pointer which you may use to control playback same way you control other clips, or null if it could not be started.
Note: due how audiochannels work internally right now, this is always same channel, and you may probably also get it as System.AudioChannels[0] (maybe not a very good idea to rely on though).

Character and "cue" arguments are used to find actual clip, this works same way as when you do cEgo.Say("&10 blablabla"); <- in this case "10" is a cue number.

as_speech argument tells whether playback has same effect on game as regular speech. At the moment this means that music volume will drop and restore after playback is finished.
as_speech = true by default, so may be omited.

Other specifics:
* will be ignored if a regular blocking voice is played;

cat

Thanks for clarifying. This means it is not what I want.
Would Cassiebsg's suggestion work?

Code: ags

currentText = "&10 A lemon!";
player.Say(currentText);

Khris

Yes, if should work that way.

The only thing I was wary about is whether it would end up in the translation file, so I might've suggested

Code: ags
  player.Say(GetTranslation(currentText));


but it's possible you have to always do that.

cat

Just confirming: Adding the line numbers manually works.

SMF spam blocked by CleanTalk