Project Zomboid

Project Zomboid

Voiced Radio and TVs
This topic has been locked
Fed-cap  [developer] 22 Mar, 2023 @ 6:48pm
[DISABLED]How to add Voice lines to the mod
If you have an eleven labs account (which is free but can be paid for more features), You may want to add more voices to different broadcasts.

This will be a quick guide explaining my process.

Requirements:

You will need:
  1. Python.
  2. An Eleven Labs account.
  3. Internet connection.
  4. VS code (recommended)

Getting the broadcast ID

First, you need to find the broadcastID you want to change. Go to media/radio/RadioData.xml

There, if you scroll down, you will see every transcript of every program. Most of them are inside ChannelEntrys (which says to which radio / TV it belongs to)

Find a BroadcastEntry you want to voice, which contains LineEntries.

The ID of the BroadcastEntry is the broadcastID, and will be the name of the audio file generated.

Getting your Eleven Labs API Key

Go to your Eleven Labs account, and press your picture.

Select profile, and it should you your API Key.

Once you have both IDs, go to automation/config.txt and write them in the appropriate places.

Running the script

With python/vscode, run the script VoiceBroadcast.py in the main folder.

It will search for the broadcast ID. if found and already voiced, It will tell you, and ask you if you want to continue or not.

Then, it will show you a transcript of what is said, colored and with the voice numbers on the left.

It will ask you to continue. Before doing that, you should head to config.txt again (if it is your first time) and make sure that the voices numbers are the ones you want and are configured correctly.

I left a cast.txt file, which says which voices I used for different characters.

You can use any voice you want, including Instant made (if you have premium). Feel free to add your own voice!

Finally, you should ALWAYS check the script.

Head into automation/tmp. there should be a transcript.txt. Open it and check the script. This are the lines that will be sent to Eleven labs. You may sometimes want to change them a little, to make it sound better.

For instance:

{Voice2}If a line is...
{Voice2}... separated like this

Will generate a weird stop in the words between "is" and "separated". I advice removing the dots, or moving "is" to the line below.

Also, You can add any sound effect. For instance, in woodcraft:

{Voice5}*bang* *bang*

Is not a voice saying bang bang, its hammer noises. Well, in automation/SoundEffects I left all the effects I used, and for hammer noises I used hammernail.ogg

You can change the line to this

{hammernail.ogg}*bang* *bang*

And instead of sending the line to Eleven Labs, it will play the .ogg file instead.

You can also add both lines and sound effects

{Voice2}{lightswitch.ogg}Let's turn on the lights

Will first read the line with the voice, then play the lightswitch sound.

You can concatenate any number of audios, but bear in mind the line should total at most 5 seconds, so avoid making it too long.

Always place the items in between brackets "{}" before the line

You can add any sound effect you want. just drop it on automation/SoundEffects, and make sure it is an .ogg file

Finally,once everything is ready, Go back to the console and write "continue"

It will calulate how many characters it will cost you from ElevenLabs, and ask you to continue again.


THIS IS YOUR FINAL CHANCE TO CHECK THAT EVERYTHING IS CORRECT


Once you are ready, write continue, and wait. After some time it should finish, and it will print an array showing the length of every line. Try keeping them below 5 seconds if possible.

You can now see the results. Either by playing the game, or playing the sound directly from media/sound/Broadcasts/{BROADCAST_ID}.ogg
Last edited by Fed-cap; 8 May, 2023 @ 7:47pm
< >
Showing 1-6 of 6 comments
Alpha Gamer 30 Mar, 2023 @ 3:05am 
If you have a free Eleven labs account and you run out of your monthly dialogue allowance, just sign up with a different email address and start again. You can effectively have as many custom voices and dialogue as you want depending on how many email accounts you make. By signing up with a hotmail, gmail, yahoo and iphone emails. I get more benefits than 2 of the monthly pay subscriptions on their site
Last edited by Alpha Gamer; 30 Mar, 2023 @ 4:00am
Fed-cap  [developer] 30 Mar, 2023 @ 1:36pm 
@AlphaGamer, They use cookies to detect multiple uses of free tier accounts from the same IP address, so they can stop this sort of abuse. However, you are kinda right and there is ways to circumvent this.

But, I wanted to have access to Instant Voice cloning for certain characters ( Like the president, who at the time was Bill Clinton) so Im paying a starter Account.
Alpha Gamer 1 Apr, 2023 @ 4:46am 
you should add howard stern. Theres lots of clean audio of him talking to get enough information for the AI to get a profile
Fed-cap  [developer] 3 Apr, 2023 @ 11:58am 
@AlphaGamer could you send me an URL link to where I could get some clean audio for him?
Im currently working on LBMW and have some voices for the hosts, so I wont change them, but I might use his voice as host for the next program?
Alpha Gamer 4 Apr, 2023 @ 11:00am 
youtube has hours of howard stern podcast videos
Runda 29 Apr, 2023 @ 6:26pm 
Did one of the dependencies update or was the wrong version imported?

File "E:\SteamLibrary\steamapps\workshop\content\108600\2950750587\mods\Voiced Radio and Tvs\VoiceBroadcast.py", line 202, in GetVoiceLines
save_bytes_to_path(dst,mp3Data)
NameError: name 'save_bytes_to_path' is not defined

there exists a 'save_audio_bytes' in the helpers import, unsure if this was renamed or I missed something. I did swap that call to utilized 'save_audio_bytes' and that seemingly worked for the first line.

Afterwards - seems to run great.
Last edited by Runda; 29 Apr, 2023 @ 6:36pm
< >
Showing 1-6 of 6 comments
Per page: 1530 50