Skip to content

Commit 808143f

Browse files
committed
Final text2voice commit
1 parent 7776ee0 commit 808143f

File tree

8 files changed

+85
-10
lines changed

8 files changed

+85
-10
lines changed

Diff for: code/__HELPERS/unsorted.dm

+3-1
Original file line numberDiff line numberDiff line change
@@ -1606,4 +1606,6 @@ proc/check_target_facings(mob/living/initator, mob/living/target)
16061606
/mob/proc/texttospeech(var/text, var/speed, var/pitch, var/accent, var/voice, var/echo)
16071607
text = texttospeechstrip(text)
16081608
lastspeak = text
1609-
ext_python("voice.py", "\"[accent]\" \"[voice]\" \"[pitch]\" \"[echo]\" \"[speed]\" \"[text]\" \"[src.ckey]\"")
1609+
ext_python("voice.py", "\"[accent]\" \"[voice]\" \"[pitch]\" \"[echo]\" \"[speed]\" \"[text]\" \"[src.ckey]\"")
1610+
1611+

Diff for: code/controllers/configuration.dm

+1-1
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@
455455
if(world.system_type == UNIX)
456456
config.python_path = "/usr/bin/env python2"
457457
else //probably windows, if not this should work anyway
458-
config.python_path = "python"
458+
config.python_path = "pythonw"
459459

460460
if("assistant_limit")
461461
config.assistantlimit = 1

Diff for: code/modules/client/preferences.dm

+29-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,10 @@ datum/preferences
102102
var/list/organ_data = list()
103103

104104
var/list/player_alt_titles = new() // the default name of a job like "Medical Doctor"
105-
105+
var/accent = "en-us"
106+
var/voice = "m1"
107+
var/pitch = 50
108+
var/talkspeed = 175
106109
var/flavor_text = ""
107110
var/med_record = ""
108111
var/sec_record = ""
@@ -176,6 +179,10 @@ datum/preferences
176179
dat += "<br>"
177180
dat += "Species: <a href='byond://?src=\ref[user];preference=species;task=input'>[species]</a><br>"
178181
dat += "Secondary Language:<br><a href='byond://?src=\ref[user];preference=language;task=input'>[language]</a><br>"
182+
dat += "Accent: <a href='byond://?src=\ref[user];preference=accent;task=input'>[accent]</a><br>"
183+
dat += "Voice: <a href='byond://?src=\ref[user];preference=voice;task=input'>[voice]</a><br>"
184+
dat += "Pitch: <a href='?_src_=prefs;preference=pitch;task=input'>[pitch]</a><br>"
185+
dat += "Talking Speed: <a href='?_src_=prefs;preference=talkspeed;task=input'>[talkspeed]</a><br>"
179186
dat += "Blood Type: <a href='byond://?src=\ref[user];preference=b_type;task=input'>[b_type]</a><br>"
180187
dat += "Skin Tone: <a href='?_src_=prefs;preference=s_tone;task=input'>[-s_tone + 35]/220<br></a>"
181188
// dat += "Skin pattern: <a href='byond://?src=\ref[user];preference=skin_style;task=input'>Adjust</a><br>"
@@ -302,6 +309,7 @@ datum/preferences
302309
dat += "<b>Ghost ears:</b> <a href='?_src_=prefs;preference=ghost_ears'><b>[(toggles & CHAT_GHOSTEARS) ? "Nearest Creatures" : "All Speech"]</b></a><br>"
303310
dat += "<b>Ghost sight:</b> <a href='?_src_=prefs;preference=ghost_sight'><b>[(toggles & CHAT_GHOSTSIGHT) ? "Nearest Creatures" : "All Emotes"]</b></a><br>"
304311
dat += "<b>Ghost radio:</b> <a href='?_src_=prefs;preference=ghost_radio'><b>[(toggles & CHAT_GHOSTRADIO) ? "Nearest Speakers" : "All Chatter"]</b></a><br>"
312+
dat += "<b>Hear player voices:</b> <a href='?_src_=prefs;preference=player_voices'><b>[(toggles & SOUND_VOICES) ? "Yes" : "No"]</b></a><br>"
305313

306314
if(config.allow_Metadata)
307315
dat += "<b>OOC Notes:</b> <a href='?_src_=prefs;preference=metadata;task=input'> Edit </a><br>"
@@ -1087,6 +1095,23 @@ datum/preferences
10871095
underwear = underwear_options.Find(new_underwear)
10881096
ShowChoices(user)
10891097

1098+
if("accent")
1099+
var/new_accent = input(user, "Choose your accent. en-us:American, en:British, en-sc:Scottish", "Character Preference") as null|anything in list("en-us", "en", "en-sc")
1100+
if(new_accent)
1101+
accent = new_accent
1102+
if("voice")
1103+
var/new_voice = input(user, "Choose your voice. f:Female, m:Male", "Character Preference") as null|anything in list("f1","m1","f2","m2","f3","m3","f4","m4","f5","m5","m6","m7")
1104+
if(new_voice)
1105+
voice = new_voice
1106+
if("pitch")
1107+
var/new_pitch = input(user, "Choose your character's voice pitch:\n(0-99) Default is 50.", "Character Preference") as num|null
1108+
if(new_pitch)
1109+
pitch = max(min( round(text2num(new_pitch)), 99),0)
1110+
if("talkspeed")
1111+
var/new_talkspeed = input(user, "Choose your character's voice talk speed:\n(140-240) Default is 175.", "Character Preference") as num|null
1112+
if(new_talkspeed)
1113+
talkspeed = max(min( round(text2num(new_talkspeed)), 240),140)
1114+
10901115
if("eyes")
10911116
var/new_eyes = input(user, "Choose your character's eye colour:", "Character Preference") as color|null
10921117
if(new_eyes)
@@ -1267,6 +1292,9 @@ datum/preferences
12671292
if("ghost_radio")
12681293
toggles ^= CHAT_GHOSTRADIO
12691294

1295+
if("player_voices")
1296+
toggles ^= SOUND_VOICES
1297+
12701298
if("save")
12711299
save_preferences()
12721300
save_character()

Diff for: code/modules/client/preferences_savefile.dm

+12
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,10 @@
120120
S["underwear"] >> underwear
121121
S["backbag"] >> backbag
122122
S["b_type"] >> b_type
123+
S["accent"] >> accent
124+
S["voice"] >> voice
125+
S["pitch"] >> pitch
126+
S["talkspeed"] >> talkspeed
123127

124128
//Jobs
125129
S["alternate_option"] >> alternate_option
@@ -174,6 +178,10 @@
174178
underwear = sanitize_integer(underwear, 1, underwear_m.len, initial(underwear))
175179
backbag = sanitize_integer(backbag, 1, backbaglist.len, initial(backbag))
176180
b_type = sanitize_text(b_type, initial(b_type))
181+
accent = sanitize_text(accent, initial(accent))
182+
voice = sanitize_text(voice, initial(voice))
183+
pitch = sanitize_text(pitch, initial(pitch))
184+
talkspeed = sanitize_text(talkspeed, initial(talkspeed))
177185

178186
alternate_option = sanitize_integer(alternate_option, 0, 2, initial(alternate_option))
179187
job_civilian_high = sanitize_integer(job_civilian_high, 0, 65535, initial(job_civilian_high))
@@ -352,6 +360,10 @@
352360
S["underwear"] << underwear
353361
S["backbag"] << backbag
354362
S["b_type"] << b_type
363+
S["accent"] << accent
364+
S["voice"] << voice
365+
S["pitch"] << pitch
366+
S["talkspeed"] << talkspeed
355367

356368
//Jobs
357369
S["alternate_option"] << alternate_option

Diff for: code/modules/client/preferences_toggles.dm

+11-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
src << "As a ghost, you will now [(prefs.toggles & CHAT_GHOSTRADIO) ? "hear all radio chat in the world" : "only hear from nearby speakers"]."
2626
prefs.save_preferences()
2727
feedback_add_details("admin_verb","TGR")
28-
28+
2929
/client/proc/toggle_hear_radio()
3030
set name = "Show/Hide RadioChatter"
3131
set category = "Preferences"
@@ -85,6 +85,15 @@
8585
src << sound(null, repeat = 0, wait = 0, volume = 85, channel = 1) // stop the jamsz
8686
feedback_add_details("admin_verb","TLobby") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc!
8787

88+
/client/verb/togglevoices()
89+
set name = "Toggle player voices"
90+
set category = "Preferences"
91+
set desc = "Toggle hearing player voice sounds"
92+
prefs.toggles ^= SOUND_VOICES
93+
prefs.save_preferences()
94+
src << "You will [(prefs.toggles & SOUND_VOICES) ? "now" : "no longer"] hear voices of players around you, or your own voice."
95+
feedback_add_details("admin_verb","TVoice") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc!
96+
8897
/client/verb/togglemidis()
8998
set name = "Hear/Silence Midis"
9099
set category = "Preferences"
@@ -181,4 +190,4 @@
181190
prefs.UI_style_alpha = UI_style_alpha_new
182191
prefs.UI_style_color = UI_style_color_new
183192
prefs.save_preferences()
184-
usr << "UI was saved"
193+
usr << "UI was saved"

Diff for: code/modules/mob/living/say.dm

+22
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,23 @@ var/list/department_radio_keys = list(
375375
if(M != src && is_speaking_radio)
376376
M:show_message("<span class='notice'>[src] talks into [used_radios.len ? used_radios[1] : "radio"]</span>")
377377

378+
if(message_mode == null)
379+
var/accent = "en-us"
380+
var/voice = "m7"
381+
var/speed = 175
382+
var/pitch = 0
383+
var/echo = 10
384+
if(istype(src, /mob/living/silicon/ai))
385+
echo = 90
386+
if(istype(src, /mob/living/silicon/robot))
387+
echo = 60
388+
if(src.client && src.client.prefs)
389+
accent = src.client.prefs.accent
390+
voice = src.client.prefs.voice
391+
speed = src.client.prefs.talkspeed
392+
pitch = src.client.prefs.pitch
393+
src:texttospeech(message, speed, pitch, accent, "+[voice]", echo)
394+
378395
var/rendered = null
379396

380397
if (length(heard_a))
@@ -389,6 +406,11 @@ var/list/department_radio_keys = list(
389406

390407
for (var/mob/M in heard_a)
391408
//BEGIN TELEPORT CHANGES
409+
if(message_mode == null && fexists("sound/playervoices/[src.ckey].ogg"))
410+
if(M.client)
411+
if(M.client.prefs)
412+
if(M.client.prefs.toggles & SOUND_VOICES)
413+
playsound(src.loc, "sound/playervoices/[src.ckey].ogg", 70, 0, 5, 1)
392414
if(!istype(M, /mob/new_player))
393415
if(M && M.stat == DEAD)
394416
if ((M.client.prefs.toggles & CHAT_GHOSTEARS) && M in onscreen)

Diff for: code/setup.dm

+1
Original file line numberDiff line numberDiff line change
@@ -659,6 +659,7 @@ var/list/TAGGERLOCATIONS = list("Disposals",
659659
#define CHAT_DEBUGLOGS 2048
660660
#define CHAT_LOOC 4096
661661
#define CHAT_GHOSTRADIO 8192
662+
#define SOUND_VOICES 16384
662663

663664

664665
#define TOGGLES_DEFAULT (SOUND_ADMINHELP|SOUND_MIDI|SOUND_AMBIENCE|SOUND_LOBBY|CHAT_OOC|CHAT_DEAD|CHAT_GHOSTEARS|CHAT_GHOSTSIGHT|CHAT_PRAYER|CHAT_RADIO|CHAT_ATTACKLOGS|CHAT_LOOC)

Diff for: scripts/voice.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,18 @@
1919
soxpath = "C:/Program Files (x86)/sox-14-4-1/"
2020
oggencpath = "C:/Program Files (x86)/WinVorbis/"
2121
text = string.replace(text, "39", "'")
22-
command = "\""+espeakpath+"espeak.exe\" -w "+playervoicespath+""+ckey+"u.wav -v"+accent+""+voice+" \""+text+"\" -p "+pitch+" -s "+speed+" -a 100"
22+
command = "\""+espeakpath+"espeak.exe\" -w \""+playervoicespath+""+ckey+"u.wav\" -v"+accent+""+voice+" \""+text+"\" -p "+pitch+" -s "+speed+" -a 100"
2323
# First we make the voice file, sounds/playervoice/keyu.wav
24+
print(command)
2425
call(command, shell=True)
25-
command2 = "\""+soxpath+"sox.exe\" "+playervoicespath+""+ckey+"u.wav \""+playervoicespath+""+ckey+".wav\" echo 1 0.5 "+echo+" .5"
26+
command2 = "\""+soxpath+"sox.exe\" \""+playervoicespath+""+ckey+"u.wav\" \""+playervoicespath+""+ckey+".wav\" echo 1 0.5 "+echo+" .5"
27+
print(command2)
2628
# Now we apply effects to it, like echo (there's lots of other effects too)
2729
call(command2, shell=True)
28-
#remove the old keyu.wav
29-
os.remove(playervoicespath+""+ckey+"u.wav")
30-
command3 = "\""+oggencpath+"OggEnc.exe\" "+playervoicespath+""+ckey+".wav"
30+
command3 = "\""+oggencpath+"OggEnc.exe\" \""+playervoicespath+""+ckey+".wav\""
3131
#Now we turn key.wav into key.ogg to reduce bandwidth
3232
call(command3, shell=True)
3333
#delete the wav
34+
os.remove(playervoicespath+""+ckey+"u.wav")
3435
os.remove(playervoicespath+""+ckey+".wav")
3536
sys.exit()

0 commit comments

Comments
 (0)