Author Topic: [SOLVED] Speech lines/voice acting for dynamically created texts  (Read 298 times)

cat

  • Mittens Baronet
    • cat worked on one or more games that won an AGS Award!
    •  
    • cat worked on one or more games that was nominated for an AGS Award!
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: Adventure Game Studio
  1. currentText = "A lemon!";

Later, I will call
Code: Adventure Game Studio
  1. 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.
« Last Edit: 21 Aug 2019, 21:17 by cat »

Cassiebsg

  • Cavefish
  • Fleeing the Cylon tyrrany...
    • Cassiebsg worked on one or more games that won an AGS Award!
    •  
    • Cassiebsg worked on one or more games that was nominated for an AGS Award!
Re: Speech lines/voice acting for dynamically created texts
« Reply #1 on: 13 Aug 2019, 22:02 »
I haven't tried it, but have you tried to add the line number to the text?

as in
Code: Adventure Game Studio
  1. currentText = "&10 A lemon!";

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

Re: Speech lines/voice acting for dynamically created texts
« Reply #2 on: 13 Aug 2019, 23:40 »
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

  • Mittens Baronet
    • cat worked on one or more games that won an AGS Award!
    •  
    • cat worked on one or more games that was nominated for an AGS Award!
Re: Speech lines/voice acting for dynamically created texts
« Reply #3 on: 14 Aug 2019, 07:43 »
Thanks for the suggestions!

Code: Adventure Game Studio
  1. currentText = "&10 A lemon!";
Good idea, I'll try that.

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.


Re: Speech lines/voice acting for dynamically created texts
« Reply #4 on: 14 Aug 2019, 08:06 »
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: Adventure Game Studio
  1. if (SubtitleEnabled) {Speech.VoiceMode = eSpeechVoiceAndText;}
  2. else
  3. {
  4.    if (IsSpeechVoxAvailable() == 1) Speech.VoiceMode = eSpeechVoiceOnly;
  5. }
  6.  

cat

  • Mittens Baronet
    • cat worked on one or more games that won an AGS Award!
    •  
    • cat worked on one or more games that was nominated for an AGS Award!
Re: Speech lines/voice acting for dynamically created texts
« Reply #5 on: 14 Aug 2019, 08:23 »
Thanks, Vincent!

Re: Speech lines/voice acting for dynamically created texts
« Reply #6 on: 14 Aug 2019, 08:27 »
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.

Re: Speech lines/voice acting for dynamically created texts
« Reply #7 on: 14 Aug 2019, 13:17 »
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;
« Last Edit: 14 Aug 2019, 13:21 by Crimson Wizard »

cat

  • Mittens Baronet
    • cat worked on one or more games that won an AGS Award!
    •  
    • cat worked on one or more games that was nominated for an AGS Award!
Re: Speech lines/voice acting for dynamically created texts
« Reply #8 on: 14 Aug 2019, 14:05 »
Thanks for clarifying. This means it is not what I want.
Would Cassiebsg's suggestion work?

Code: Adventure Game Studio
  1. currentText = "&10 A lemon!";
  2. player.Say(currentText);
  3.  

Khris

  • partook in silencing a crtitc despite facts
    • Lifetime Achievement Award Winner
    • I can help with play testing
    • I can help with scripting
    • I can help with translating
    • Khris worked on one or more games that was nominated for an AGS Award!
Re: Speech lines/voice acting for dynamically created texts
« Reply #9 on: 14 Aug 2019, 14:46 »
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: Adventure Game Studio
  1.   player.Say(GetTranslation(currentText));

but it's possible you have to always do that.
Fail at Floaty Rog' now!  still having to deal with what games are going through

cat

  • Mittens Baronet
    • cat worked on one or more games that won an AGS Award!
    •  
    • cat worked on one or more games that was nominated for an AGS Award!
Re: Speech lines/voice acting for dynamically created texts
« Reply #10 on: 21 Aug 2019, 21:16 »
Just confirming: Adding the line numbers manually works.