Jump to content

String JTAC voice files together to make a sentence


Recommended Posts

Posted

Gents,

 

I'd like to use the speech sound files in a trigger to form a sentence, but I'm not sure how to do it without making multiple triggers in succession.

 

Example sentence would be something like, "TOT 05."

 

I thought I might be able to use a sleep command between the ACTIONS within the trigger, but that doesn't seem to work.

 

It would be nice to have the ability to do this instead of recording a custom sound file.

 

TYIA ~

Posted

Outside of making a custom sound file, you will need to do it with multiple triggers. I did it with On Station. With triggers it was pretty annoying to setup and to add stuff to it. With scripting it is more straight forward and you can get a more fluid sentence structure out of it. With On Station I basically created a DB of sound files like this:

 

sFiles[#sFiles + 1] = {file = 'hq_out.wav', len = 0.8, text = 'out', voice = 'wizard'}
sFiles[#sFiles + 1] = {file = 'hq_over.wav', len = 1.5, text = 'over', voice = 'wizard'}
sFiles[#sFiles + 1] = {file = 'hq_roger.wav', len = 0.9, text = 'roger', voice = 'wizard'}
sFiles[#sFiles + 1] = {file = 'hq_Tusk.wav', len = 0.9, text = 'Tusk', voice = 'wizard'}
sFiles[#sFiles + 1] = {file = 'hq_ThisIsWizard.wav', len = 1.3, text = 'this is Wizard', voice = 'wizard'}

 

It contains the name of the sound file, the length, the text to be displayed, and who is saying it. There was a scripting function setup to search the DB and find the appropriate DB entry. I then had a scripting function setup to populate and format the message based on a few input values. Here is a code fragment from it...

 

-- say hello
	m[#m+1] = findFile(s, r)
	m[#m+1] = ', '
	if s == 'tusk' then
		m[#m+1] = findFile(s, 'this is Tusk')
	elseif s == 'wizard' then
		m[#m+1] = findFile(s, 'this is Wizard')
	elseif s == 'spectre' then
		m[#m+1] = findFile(s, 'this is Spectre')
	end
	m[#m+1] = '. '
	m[#m+1] = findFile(s, 'Over')
	m[#m+1] = '. \n\n'

 

First it finds the file where the sender says the receivers name, then says its own name, and then over. Together it comes out to "Tusk, this is Wizard, Over." The message is one big table of entries with the sound files actually being just a copy of the sounds DB entry. When the whole thing is compiled it is then parsed by another function to output the text and sound files. The relevant text gets placed into a text message, while the sounds are entered into a play queue based on the length of the sound files.

 

A long time ago I did it with triggers and it was stupid complex. The overall gist of it was to set a flag and used time since flag conditions to send the audio.

Switched Condition>Time since Flag X is 1> OutSound('hq_Tusk.wav')

Switched Condition>Time since Flag X is 2> OutSound('hq_ThisIsWizard.wav')

Switched Condition>Time since Flag X is 4> OutSound('hq_over.wav')

The right man in the wrong place makes all the difference in the world.

Current Projects:  Grayflag ServerScripting Wiki

Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread)

 SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum

Posted

Cool. Are there any significant negatives to a script like this? Like high cpu workload or huge mission sizes? Do the sounds included in the DB get saved into the .miz or does it draw them from the client's game folder (ie. how careful do I need to be about populating the DB)?

Posted

Unfortunately I don't think you can play sounds directly from a game folder. For sounds with scripting you have to create a trigger in the mission that uses the sound. That doesn't mean the trigger has to execute, it just has to be there so the files get embedded and won't be deleted. With On Station I think I used a Mission Start>Time More>Play Sound(x),Play Sound (Y), etc.

 

Negatives in terms of performance is down to how you write it and how it executes. It should be a pretty light weight overall. File size is mostly down to the sound files themselves. How many there are, how long, and most importantly what codec you used. For a while I used ogg and which consisted of 57 files at a total of 2,000 KB. I later changed it to use GSM 6.10 for wav and got the files down to 680 KB.

The right man in the wrong place makes all the difference in the world.

Current Projects:  Grayflag ServerScripting Wiki

Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread)

 SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum

Posted
Unfortunately I don't think you can play sounds directly from a game folder. For sounds with scripting you have to create a trigger in the mission that uses the sound.

 

What does that mean exactly? From the game folder means I can not play a sound from [game directory]\mysounds\ for example? But I can play sounds located in the mission file?

 

So if I have a "mysound.ogg" in the mission file, I can just script

sFiles[#sFiles + 1] = {file = 'mysound.ogg', len = 0.8, text = 'my cool text', voice = 'wizard'}

?

 

What is that voice= parameter for?

"Sieh nur, wie majestätisch du durch die Luft segelst. Wie ein Adler. Ein fetter Adler."

http://www.space-view.net

Posted

If you want to play sounds in your mission with scripting the file has to be embedded into the .miz file, see my earlier point on using a trigger to do that. Then you have to play the actual sound itself, there are a few ways to do it. The most direct way is with the scripting function trigger.action.outSound(). It is the scripting equivalent to the play sound trigger.

 

trigger.action.outSound('mysound.ogg')

 

 

 

The below code fragment is part of a specific script I made for a mission and is not syntax that DCS or even MIST uses. It is completely customized for the specific needs of that mission.

 

sFiles[#sFiles + 1] = {file = 'mysound.ogg', len = 0.8, text = 'my cool text', voice = 'wizard'}

 

You can see the mission and the full code here on my github The whole point of it was to experiment with random objectives and how to get that information to the players before scripting was even a thing. I later adapted it to use the scripting engine which you can see from that lua file. It was literally 750ish triggers and it didn't always work correctly. The mission contained 2-3 different voices that were able to "talk" to one another using 50+ sound files of words or short statements. It is kind of like how AI flights communicate to players in game. So that table simply defines the file to play, how long it is, what the text should say, and who is saying it. A bunch of other scripts decided what and when to play a given audio file.

 

I've attached an image that shows the end result. The code snippet I posted with the "say hello" comment is the first line highlighted in red. Everything with a line separating it is its own sound file. Everything is red is communicated by "Wizard" while everything in green is by "Tusk". The entire text message is displayed at once, while the sound files are played one at a time in the correct sequence. I didn't spend a whole lot of time tweaking the timings and voice recordings so it sounds "natural", so it is very robotic, but it is functional. In fact most of the audio is at least 5 years old now.

1340972090_Ingamebriefingexample_breakdown.jpg.c5cdc32d878d1d771c226aa2e6a63011.jpg

The right man in the wrong place makes all the difference in the world.

Current Projects:  Grayflag ServerScripting Wiki

Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread)

 SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum

Posted

Ok so basically I just have to embed the file (via trigger just to get it into the .miz? Can't I just open the miz with 7zip and put it in there?) and do basically

 

trigger.action.outSound('mysound1.ogg')

[sleep for the length of the file]

trigger.action.outSound('mysound2.ogg')

[sleep for the length of the file]

trigger.action.outSound('mysound3.ogg')

 

..to create a dynamically built sentence..

"Sieh nur, wie majestätisch du durch die Luft segelst. Wie ein Adler. Ein fetter Adler."

http://www.space-view.net

Posted

You can put a file directly into the .miz. However whenever you open up the mission in the editor and save, any file not associated with a trigger or AI action will be removed. So it is better to just add it to a trigger to ensure that it will remain in the miz.

The right man in the wrong place makes all the difference in the world.

Current Projects:  Grayflag ServerScripting Wiki

Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread)

 SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...