Adding Custom Voice Files

Tutorial collection, comprehensive listings on main site.

Adding Custom Voice Files

Postby Tutorial on Thu Dec 04, 2008 10:34 am

category
General Half-Life 2/Sound

description
Add your own voices with sub-titles to the Source Engine.

keywords
voices, voice, custom voice, sub, title, sub titles, soundscript, sound, scripts.

Tutorial Description

In this Tutorial, you'll learn about :

  • Voice recording : Create a voice as a Wav file
  • Soundscript : Use that voice to make it a Soundscript recognizable by the engine as a "Game sound" (.Wav are what we call "Raw sound") and on which it's possible to add an attenuation and an origin (sound is coming from the suit, another npc, etc...)
  • Subtitle : Give your sound a personalized caption (text, color, etc...) used for subtitles


Create a voice

To register your voice, I use Audacity. It does all I need, with a lot of easy-to-use tools.
It even integrates a very helpful "Noise Removal" tool.
Of course, it's your choice whether you use Audacity or not, but here's a walkthrough coming along with that program.
If you know how to create your own Wav, you can skip this part and go directly to the Create a Soundscript part.

1) Record your voice until you get the perfect sound record (remember to speak slowly)
Image

Note : According to the Valve Dev Wiki, speech files should be 4-bit Microsoft ADPCM ("MSADPCM") mono .WAV files at 44kHz (44100Hz). Well, my file is 16-bit and it works perfectly.

2) Adjust the volume.
I have to add at least 12dB, but this probably depends of your micro.
Image

Note : At this point, you might want to test the volume of your voice in game... which is a pretty good idea !
It's always possible to slightly modify the volume afterwards, but you'd better have a correct volume right now.
The best way to know if your sound is loud enough, is to compare it to an existing Half-Life² voice sound and see if you're good. These sounds can be found in the gcf files.

If you hear some noise as you increase the volume :
a) Select a small piece of your record where you can hear only the noise (not your voice)

b) Go to Effects > Noise Removal
Image

c) Press the "Get Noise Profile" Button
Image

d) Select your whole record (CTRL + A)
Image

e) Get back to Effects > Noise Removal

f) Move the horizontal scrolling bar to the extreme left (otherwise your record will be way too much truncated)

g) Finally, press the "Remove Noise" button
Image


3) Now, select the piece of record you want to save as a Wav (I often have rubbish at the beginning and end of the recorded voice)

4) Clic on File > Export Selection As Wav...
Image
Name it, and save it.

Now, we have the raw voice ! Yeah !


Create a Soundscript

Definition : A soundscript is a little script written in a txt file that will associate information to the sound we just recorded, like the name, the volume, the channel used (source), etc...

1) Go to the "yourModFolder\scripts" folder

2) Open the file "game_sounds_manifest.txt" :
Image
This manifest will tell the engine which files contain the soundscripts and which must be read in order for the sounds to be preloaded / precached.

You’ll see something like that :

Code: Select all
game_sounds_manifest
{
   // HL2 World, Ambient Generic, Items, Physics, Vehicles
   "precache_file"      "scripts/game_sounds_world.txt"
       ...

   // Game level sounds
   "precache_file"      "scripts/level_sounds_eli_lab.txt"
       ...

   // NPC Sounds
   "precache_file"      "scripts/npc_sounds_eli.txt"
       ...

}

The manifest is filled with the name of all files containing the soundscripts used by Half-Life².
We don’t need them, so…

3) Write inside the manifest :
Code: Select all
game_sounds_manifest
{
   // My Custom NPC Sounds
   "precache_file"      "scripts/npc_sounds_kyl.txt"   
   ...
}

We say that when Hammer, FacePoser or the game starts, it should preload the Soundscripts inside the file "scripts/npc_sounds_kyl.txt".
If you have many actors, you can make one file per actor.

4) Save the manifest, and close it. We won't need it anymore.

5) Create the file "npc_sounds_kyl.txt" in the "scripts" folder.
Image

6) Open it, and let's create a soundscript for a normaly speaking actor voice.
Here's the structure I use :

Code: Select all
"npc_kyl.01.kyl01"
{
   "channel"   "CHAN_VOICE"
   "volume"   "0.6"
   "pitch"      "PITCH_NORM"

   "soundlevel"   "SNDLVL_TALKING"   

   "wave"      "rebellion\vo\level01\kyl01.wav"
}

...where :

npc_kyl.01.kyl01= Name of the soundscript
CHAN_VOICE = Channel used (source)
SNDLVL_TALKING = Sound attenuation / effect
rebellion\vo\level01\kyl01.wav = The path of the sound inside the yourModFolder\sounds folder

Learn more : The properties of each Soundscript keyvalue and its effect.

Tip : If you want the voice to come from the player, as if he was speaking, use :

Code: Select all
"npc_kyl.01.kyl01"
{
   "channel"   "CHAN_WEAPON"
        ...
   "wave"      "#rebellion\vo\level01\kyl01.wav"
}

CHAN_WEAPON makes the sound come from the player / suit / weapon.
# before the sound path specifies you don't want any DFX on this sound (resonance when you're in a cave, etc...)
Learn more : Sound Characters

7) Save and close.
Now, we have a soundscript called "npc_kyl.01.kyl01" which can be used within the source engine.


Note : Now, should Soundscripts be created for every sound you used in your Source games ? That's really up to you. The advantage of Soundscripts is that it allows you to fully control the properties of your sounds. This can be useful for background music (no effect), or to control the Sound level (quiet or very loud) of your sound, and is an obligation for subtitles.

Learn more : Soundscripts


Give the Soundscript a Caption

The caption is simply the text of your voice, used within FacePoser or to be shown as subtitles in Half-Life².


1) Go to the "yourModFolder\resources" folder
Image

2) Open the file "closecaption_english.txt"

It should look like this :

Code: Select all
lang
{
   Language "English" //(or "French", etc)
   Tokens
   {
      // Captions defined here.
      nameOfSoundScript   "This is the caption."
   }
}

3) Write the caption of our Soundscript :

Code: Select all
lang
{
   Language "English"
   Tokens
   {       
      npc_kyl.01.kyl01      "<clr:96,141,108>Cheers mate ! How are you doin' ?"
   }
}

... where :
npc_kyl.01.kyl01 = The name of the Soundscript
<clr:96,141,108>Cheers mate ! How are you doin' ? = The caption of the sound

Tip : I wrote <clr:96,141,108> before the caption (but inside the ""), which will give a green color to the text. Play with the RGB color values to get the color of your choice.
It's also possible to use <I>text<I> for italic text, <B>text<B> for bold text and <CR> to return to the line. Note the capital letters.

3) Save and close.


Note : Obviously, caption are useful only for voice sounds. Don't bother to create a caption for environment sounds.

Learn more : Closed captions


Congratulations !
At this stage, you have a correct Soundscript wich can be used within FacePoser and Hammer.

FacePoser :
Image
Image

Hammer :
Image

In the next Tutorials, we'll learn how to create a Faceposer scene, using soundscripts.

Until then, enjoy and have fun !

Kyl'
- Don't send PM's to this user -
Tutorial
Not A Real User
 
Joined: Sun Mar 06, 2005 11:00 pm

Re: Adding Custom Voice Files

Postby kkirspel on Wed Dec 24, 2008 8:12 am

I was looking for something like this...
Also, does anyone know how to edit (or just use) a music file and play it in game, like what was done in Portal: Prelude with "Rock You Like A Hurricane" and some "I Need To Survive" song. Actually this tut pretty much tells how to add the file so the engine will have it (after any conversions, I suppose), so I guess I'm just asking is how you would go about removing certain parts of the song, like vocals, and just have an undertone or beat?
The inspiration as to why I'm here: Adam Foster; Minerva. Great job man.
User avatar
kkirspel
Pheropod
Pheropod
 
Joined: Wed Dec 03, 2008 6:34 pm
Location: Columbus, GA, USA

Re: Adding Custom Voice Files

Postby Kyl' on Wed Dec 24, 2008 10:42 am

Hey Kkirspel :-)

You should check this out ! (Or google for more info :-) )

Afterward, save it as an MP3 or Wav, and place it in your mod's sound folder. In Hammer, get the file with an ambient_generic entity. And there you go :-)
No need to create a soundscript for background music... unless you want to add a special environment effect on it !

Cheers !
Image
User avatar
Kyl'
Been Here A While
Been Here A While
 
Joined: Tue Sep 02, 2008 2:28 pm

Re: Adding Custom Voice Files

Postby kkirspel on Fri Dec 26, 2008 7:34 am

Hey thanks!
Yeah, I'm looking at it and Audacity now, and I'm thinking i could run the particular songs through DrJava with Sound.java and edit out the sounds values a bit better (though its a much more tedious task to do, tweaking the code little by little).
Thanks, though, got me on the right track and idea!
(google, why didn't I think of that...)
The inspiration as to why I'm here: Adam Foster; Minerva. Great job man.
User avatar
kkirspel
Pheropod
Pheropod
 
Joined: Wed Dec 03, 2008 6:34 pm
Location: Columbus, GA, USA

Re: Adding Custom Voice Files

Postby kkirspel on Fri Dec 26, 2008 7:50 am

Actually... I guess I'll just have to make do with these other editing programs...
(DrJava is having an issue using my audio file; dr. supports wav, au, aiff files but its still has a problem with a wav file thats been converted from mp3...)
The inspiration as to why I'm here: Adam Foster; Minerva. Great job man.
User avatar
kkirspel
Pheropod
Pheropod
 
Joined: Wed Dec 03, 2008 6:34 pm
Location: Columbus, GA, USA

Re: Adding Custom Voice Files

Postby Dr. KillPatient on Sat Jan 24, 2009 2:24 pm

Strange. My Half-Life 2 folder doesn't have a Scripts folder in it. Should I just create one?

And when I put Still Alive in my Sounds folder (for G-man to sing =D) it doesn't show up in the sounds browser.
We cannot read the Freeman's optical buds.
User avatar
Dr. KillPatient
Regular
Regular
 
Joined: Sun Jan 18, 2009 2:06 am

Re: Adding Custom Voice Files

Postby Kyl' on Sat Jan 24, 2009 4:34 pm

If you're using the Episode one or two game, then yeah, you'll have to create the "script" folder (the original one is stored in a GCF file).

In Faceposer, make sure you've checked "Show all Sounds", and that you've made a soundscript of your sound.

Cheers ;-)
Last edited by Kyl' on Mon Jan 26, 2009 11:25 am, edited 1 time in total.
Image
User avatar
Kyl'
Been Here A While
Been Here A While
 
Joined: Tue Sep 02, 2008 2:28 pm

Re: Adding Custom Voice Files

Postby korge on Mon Jan 26, 2009 7:22 am

Thanks kyle. Now I can feature lil wayne in my shooter mod [/sarcasm]
zombie@computer wrote:Thank god the government knows best.
User avatar
korge
Pheropod
Pheropod
 
Joined: Fri Dec 28, 2007 4:16 pm

Re: Adding Custom Voice Files

Postby hodg9740 on Sun Feb 08, 2009 7:59 pm

Hey, I'm having some problems finding my .wav in face poser. All I seem to be getting are sound files from the original Half-Life 2 game(s). What do I do?
hodg9740
Member
Member
 
Joined: Sun Feb 08, 2009 7:57 pm

Re: Adding Custom Voice Files

Postby Kyl' on Fri Feb 13, 2009 11:30 am

Yo !
Might be different things :
1) Make sure you launch Faceposer with your mod properties (your mod must be selected in the Source SDK window when you start Faceposer).
2) To show raw sounds (.wav), check the "Show All Sounds" box.

Hope this helps !
Image
User avatar
Kyl'
Been Here A While
Been Here A While
 
Joined: Tue Sep 02, 2008 2:28 pm

Re: Adding Custom Voice Files

Postby hodg9740 on Sun Feb 15, 2009 10:33 pm

OK, that helped. I can see it in the Cache now, but the sound doesn't appear in the channel bar. It shows up (and I can hear it) just fine in the Phoneme editor, and I saved the file EXACTLY per Valve recommendations. Thoughts?

Oh yeah, and btw, my file path is a tad different than yous

My Mod is called 'unsung'
My Sound folder is simply called 'sound'
And the dialogue is a test sound titled 'unsung1.wav' and is saved in the sound folder.

So my soundscript looks like this:

"npc_lord.lord"
{
"channel" "CHAN_VOICE"
"volume" "0.6"
"pitch" "PITCH_NORM"

"soundlevel" "SNDLVL_TALKING"

"wave" unsung\sound\unsung1.wav
}

Like I said, it shows up in the cache when I go to add a .WAV in faceposer, but I don't see the sound data show up in the task bar.
hodg9740
Member
Member
 
Joined: Sun Feb 08, 2009 7:57 pm

Re: Adding Custom Voice Files

Postby Kyl' on Wed Feb 18, 2009 2:49 pm

Hey :-)

Face poser is findig the soundscript, but not the .wav. So check the link to that wav file.

Replace that line :
"wave" unsung\sound\unsung1.wav

by
"wave" "unsung1.wav"

The "yourMod\sound" folder is the root, no need to specify this. In your example, you have your soundscript looking for a wav file in the "yourMod\sound\unsung\sound" folder. Which isn't what we want :-)

Hope this helps !
Image
User avatar
Kyl'
Been Here A While
Been Here A While
 
Joined: Tue Sep 02, 2008 2:28 pm

Re: Adding Custom Voice Files

Postby hodg9740 on Wed Feb 18, 2009 6:16 pm

Well I'll be! just before I was about to chuck my PC out the window. Thanks Kyl, good luck with Rebellion, and wish me luck on Unsung.
hodg9740
Member
Member
 
Joined: Sun Feb 08, 2009 7:57 pm

Re: Adding Custom Voice Files

Postby Kyl' on Sun Apr 12, 2009 9:52 am

A little mistake in that tut' (Sorry Hodg9740 had to be the tester...).

Remove the line :
3) Remove all the file names (all what’s between the { }).

Since you must NOT remove them, just add your own soundscripts file name somewhere in that file.

All my apologies for the inconvenience it may have caused.
Image
User avatar
Kyl'
Been Here A While
Been Here A While
 
Joined: Tue Sep 02, 2008 2:28 pm

Re: Adding Custom Voice Files

Postby geekofalltrades on Sat Aug 15, 2009 5:30 am

Okay, this is a bit of a necropost, but I have a question concerning Portal. I'm creating a Portal mappack, and I have a voice actor on board to record some custom GLaDOS dialogue. GLaDOS' dialogue is handled through scene files in Hammer with logic_choreographed_scene. I have my raw sound, and I'm trying to create the soundscript using this tutorial. The problem is that my mod, Overture, isn't a SourceMod; it's a Bonus Map. As such, it does not have a game_sounds_manifest.txt file. I tried just skipping the step where you define your sound in the manifest, and while I have a script file (entitled simply "overture.txt," located at portal/portal/scripts/overture.txt) and a sound file (located at portal/portal/sound/overture/powerdown.wav), my soundscript won't show up in faceposer so that I can insert it into a scene file. Do you know of a way to create scene files for non-SourceMods?

EDIT: If I include an updated version of game_sounds_manifest.txt with my bonus map, will it override the file found in the portal GCF? If so, this could solve my problem. Maybe I'll give that a try.

DOUBLE EDIT: Well, I'll be, I've solved my own problem. I apologize for the epic necropost.
Image
Image
It's always tragic to see a family torn apart by something so simple as a pack of wolves.
User avatar
geekofalltrades
Dumpling
Dumpling
 
Joined: Sat Jun 21, 2008 6:35 am
Next

Return to Tutorials

Who is online

Users browsing this forum: No registered users