adding voicespeech

Started by Shade, Sun 30/10/2005 09:42:58

Previous topic - Next topic

Shade

addind voicespeech

not long ago i made this (ags 2.62):

Code: ags
function Speech(int who, int Face, const string text){
Ã,  SetButtonPic(5, 0, 1, Face);
Ã,  SetLabelColor(5, 1, character[who].SpeechColor);
Ã,  SetLabelText(5, 1, text);
Ã,  GUIOn(5);
Ã,  WaitMouseKey(((StrLen(text) / game.text_speed) + 1) * GetGameSpeed());
Ã,  GUIOff(5);
}


and Ashen improved it (ags 2.7):

Code: ags
function Speech (Character *Who, int expression, string message){
Ã,  btnPortrait.Animate(Who.SpeechView, expression, 3, eRepeat);
Ã,  lblText.TextColor = Who.SpeechColor;
Ã,  lblText.SetText(message);
Ã,  gDispgui.Visible = true;
Ã,  WaitKey (((StrLen(message) / game.text_speed) + 1) * GetGameSpeed());
Ã,  gDispgui.Visible = false;
}


i thought of adding voice speech to this so that this "expression-speech-style" (how i like to call it) has the same features as the sierra-style-speech (of course it's even better ;)). but there is one big word in my head which i can't erase. this word looks like this: HOW.

one could do it with playmp3file("ego1.mp3"); or something like this but then one have to copy all voicespeech files into the compiled folder.
with playmusic or playsound it gets even more complicated.

antoher way could be to replace the lblText.SetText(message); line with e.g. cEgo.SayAt command. then one can put the text right beside the expression and handle the voicespeech with &1, &2, etc...but i don't like this because this limits the flexibility.

any ideas? thx

ManicMatt

Don't get excited, I'm probably going to give you the wrong answer.

But in the light of there being no one else here yet, and that I have speech in my game I'm making, maybe I can help?

1)That code means nothing to me.

2)I record all my speech via the free windows program "Sound recorder" that's used in conjunction with my microphone. (However the files are massive unless you degrade them)

3)I then save them as ego1. ego2, etc

4)Before any spoken text in AGS, I put &1 so it uses ego1.

EG:

"&1 Hello!"

You probably know all that, right? Ah well! Just re-read the last paragraph. Oops. Still.. sound recorder, yes?

Janik

I'm sure Shade can handle recording the sound - the issue is how to play it in a tidy way.

Here's an idea: How about having an invisible character like cTalker that is always in the same room. You also use SetSpeechFont () to set the speech font to an empty font - all letters are blank. Then, in addition to

lblText.SetText(message);

you add

cTalker.Say(message);

and it takes care of doing the talking, and if &1 or whatever is in the message, then it plays that. It should be a simple matter to remove the &12 from the text you display. All voice files would have to be called "TALK##.mp3", but that's not a big deal I imagine.


I'm interested in how you handle this because I'd like to handle the differing expressions too. What I'd like to know is how you integrate this system with dialogs? Or do you not have dialogs (by which I mean choices for conversations) in your game?
I wonder also if this system could work with the voice-speech lip sync using the Pamela program (I don't know how well it works but it looks very cool).
Play pen and paper D&D? Then try DM Genie - software for Dungeons and Dragons!

strazer

Good idea. You could also add:

  Who.SayAt(0, 0, 0, message); // say text but hidden (width 0), so voice speech plays

This way, the &1 etc. stuff still works and you don't need the WaitKey since SayAt is blocking already.

See http://www.adventuregamestudio.co.uk/yabb/index.php?topic=22433

Elliott Hird

How about that mysterious command that isn't documented, PlaySpeech? Play around with it.

Ashen

Not only is it undocumented, I don't know that it actually works - I get an 'Undefined token' error.

Please don't suggest people 'play around' with undocumented features, that way madness (and possibly much bigger scripting problems) lies. Of course, if you can also explain how to use them -  go for it.
I know what you're thinking ... Don't think that.

Gilbert

Agreed with Ashen, it's probably just some test codes CJ threw in and forgot to remove, it probably won't work anyway.

Shade

all right i put it this way:

Code: ags
function Speech(int who, int Face, const string text){
Ã,  SetButtonPic(5, 0, 1, Face);
Ã,  SetLabelColor(5, 1, character[who].SpeechColor);
Ã,  SetLabelText(5, 1, text);
Ã,  GUIOn(5);
Ã,  DisplaySpeechAt(0, 0, 0, who, text);Ã,  
Ã,  GUIOff(5);
}


everything works fine but the problem is that the gui doesn't close after the DisplaySpeechAt command. it's the same with Who.SayAt . i am to stupid to solve this problem.

QuoteI'm interested in how you handle this because I'd like to handle the differing expressions too.

first of all this script is used in the way of the "displayspeech" or the "player.say" command. if you want to use this in dialogs it gets a little bit more complicated.
1) for every dialog option you have to set up a "run-script x" command.
2) then go to the "dialog_request" section in your global-script
3) do something like this:

if (param == 1){
//conversation
}
if (param == 2){...

the params are your dialog options now. you just have to keep track on which param belongs to which dialog option. as you should have noticed you don't have to use the dialog editor for the conversations.
i am not good enough to work this out so that it's easier but i think one can work with this.
in my first version (ags 2.62) you just have the possibility to use different pics (expressions) without any animation.
in the second version (ags2.7) Ashen implemented animations for the expression.
in both cases you don't use "speech views" so you can't use lip-sync

Ashen

It shouldn't make any difference, but what if you use gui[5].Visible = false; (gDispgui.Visible = false for the second version) instead of GUIOff(5)? I'm not sure that that is the problem, but the engine can be a little buggy using the older commands.

Also, took me a while to remember this as I've never used voice speech, and it might be usless now, but:
QuoteSetVoiceMode
SetVoiceMode (VoiceMode)

Changes whether voice speech is used with dialog lines. The default is on if the voice file is present, or off otherwise.

Look it up for more details, but the relevant parameter is eSpeechVoiceOnly - no need to use SayAt, as the text won't be displayed. If you're using the animated method, however, you'd need to use a custom property instead of Character.SpeechView to set which view to use.

Quote
in both cases you don't use "speech views" so you can't use lip-sync

However, if you really wanted to, you could probably work lip-sync in. Using Janik's idea of a dummy cTalker character for instance - instead of a button to display the view, have a transparent patch in the GUI, put cTalker behind it, set the view and loop accordingly, and in theory it should lip-sync the lines. (I say 'in theory', as I have even less experience with using lip-sync than with voice speech.)
I know what you're thinking ... Don't think that.

strazer

Try putting "Wait(1);" after the GUIOff command.
But yeah, if you're using AGS v2.7, start using new-style scripting, the old commands will eventually become obsolete so it's best to familiarize yourself with the new commands.

Shade

i think you got me wrong but thats my fault. i am upgrading both versions of the script. some people out there are still using ags 2.62 and probably want to use this either. so i am quiet familiar to the new style scripting.

QuoteTry putting "Wait(1);" after the GUIOff command.
QuoteSetVoiceMode (VoiceMode)

tried this but doesn't work. i also changed the command order but nothing helps the gui doesn't close. i but wait commands in every position but it has no effect.

QuoteHowever, if you really wanted to, you could probably work lip-sync in

i am to lazy to try it because i don't need it at the momentÃ,  :) but if Janik has the idea of how to do it then he can probably improve it (if he wants to of course).

here is what i have in new style scripting:

Code: ags
function Speech (Character *Who, int expression, const string message){
Ã,  btnPortrait.Animate(Who.SpeechView, expression, 3, eRepeat);
Ã,  lblText.TextColor = Who.SpeechColor;
Ã,  lblText.SetText(message);
Ã,  gDispgui.Visible = true;
Ã,  Who.Say(message);
Ã,  gDispgui.Visible = false;
Ã,  Wait(1);
}


i put the setvoicemode command into the game_start function.

Elliott Hird

Don't. That means more copying and pasting. You could do that in a module tho... *hint hint*

SMF spam blocked by CleanTalk