Source Code Project Mantis - FSSCP
View Issue Details
0002638FSSCPspeechpublic2012-04-13 00:202015-04-23 13:39
Reportergereedy 
Assigned ToEchelon9 
PrioritynormalSeverityfeatureReproducibilityalways
Statuscode reviewResolutionopen 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version 
Summary0002638: Support speech on OSX
DescriptionThis patch implements text-to-speech for mac os x.
TagsNo tags attached.
Attached Filespatch macspeech.patch (5,716) 2012-04-13 00:20
http://scp.indiegames.us/mantis/file_download.php?file_id=1828&type=bug
patch macspeech2.patch (5,747) 2012-04-13 15:54
http://scp.indiegames.us/mantis/file_download.php?file_id=1829&type=bug
patch macspeech3.patch (5,999) 2012-08-14 10:16
http://scp.indiegames.us/mantis/file_download.php?file_id=1932&type=bug
patch macspeech4.patch (4,887) 2014-06-30 18:20
http://scp.indiegames.us/mantis/file_download.php?file_id=2435&type=bug
patch macspeech5.patch (5,020) 2015-04-23 13:09
http://scp.indiegames.us/mantis/file_download.php?file_id=2703&type=bug

Notes
(0013464)
gereedy   
2012-04-13 15:54   
Oops, I forgot to release the strings. Here's an updated patch.
(0013479)
Echelon9   
2012-04-23 10:08   
I've got this cleanly compiled into a build, but at a bit of a loss to actually get it working in game.

Is there a system-wide setting (i.e. in Preferences) that I need to set before this will work. Using OS X 10.7 here.
(0013490)
gereedy   
2012-04-30 00:26   
Oh yeah, I had to edit the fs2_open.ini file in ~/Library/FS2_Open and add the following lines:

SpeechTechroom=1
SpeechBriefings=1
SpeechIngame=1
SpeechMulti=1

I've not seen any other way (launcher or in-game) to set these.
(0013492)
Echelon9   
2012-04-30 11:30   
Hrmm, I've tried setting those as well as setting them to 0, as per the code.

Across Debug and Retail, no luck getting this working...
(0013515)
gereedy   
2012-05-03 23:00   
I think the 0 in the code is the default value if none is set, they need to be 1 to activate speech.

How are you building? The only thing I can think of is that you're building without FS2_SPEECH defined.

FYI, I'm on Lion as well and used the Xcode 4 project. The patch include the changes to the project file to turn that define on.
(0013530)
chief1983   
2012-05-09 15:07   
Huh, and here I thought we'd need to be using Festival across the board.
(0013905)
Echelon9   
2012-08-14 09:51   
Okay, by using this patch and forcing speech at startup with the -query_speech command line option, I hear part of the initial testing "Welcome to FS..." before Freespace crashes.

Looks like there's some memory corruption going on.

// fs2_open.log ------------------------------------------------------------

Initializing OpenAL...
  OpenAL Vendor : Apple Computer Inc.
  OpenAL Renderer : Software
  OpenAL Version : 1.1

  Found extension "AL_EXT_float32".

  Sample rate: 0 (44100)
  EFX enabled: NO
  Playback device: Built-in Output
  Capture device: Built-in Microphone
... OpenAL successfully initialized!
Why are you trying to free a NULL pointer? [fsmemory.cpp(19)]
Why are you trying to free a NULL pointer? [fsmemory.cpp(19)]
Why are you trying to free a NULL pointer? [fsmemory.cpp(19)]
Why are you trying to free a NULL pointer? [fsmemory.cpp(19)]
Why are you trying to free a NULL pointer? [fsmemory.cpp(19)]
Why are you trying to free a NULL pointer? [fsmemory.cpp(19)]

// Crash reporter ------------------------------------------------------------
Thread 3 Crashed:
0 FS2_Open-Inferno (debug) 0x0057bb00 _vm_free(void*, char*, int) + 128 (stubs.cpp:687)
1 FS2_Open-Inferno (debug) 0x000035cb operator delete(void*) + 43 (fsmemory.cpp:19)
2 com.apple.speech.synthesis.MacinTalkSynthesizer 0x07b3e4f0 MTBEDelayedNotifier::ForwardUnit() + 102
3 com.apple.speech.synthesis.MacinTalkSynthesizer 0x07b3bcbe MTCBSegmentProducer::NextSegment(MTMBSegment*) + 582
4 com.apple.speech.synthesis.MacinTalkSynthesizer 0x07b3b98e MTMBSmoothSegment::NextSegment(MTMBSegment*) + 90
5 com.apple.speech.synthesis.MacinTalkSynthesizer 0x07b6b488 non-virtual thunk to MTMBSmoothSegment::NextSegment(MTMBSegment*) + 27
6 com.apple.speech.synthesis.MacinTalkSynthesizer 0x07b3b873 MTMBChangePitch::NextSegment(MTMBSegment*) + 145
7 com.apple.speech.synthesis.MacinTalkSynthesizer 0x07b6b2b5 non-virtual thunk to MTMBChangePitch::NextSegment(MTMBSegment*) + 27
8 com.apple.speech.synthesis.MacinTalkSynthesizer 0x07b3b27a MTMBBlend::NextSegment(MTMBSegment*) + 160
9 com.apple.speech.synthesis.MacinTalkSynthesizer 0x07b6b368 non-virtual thunk to MTMBBlend::NextSegment(MTMBSegment*) + 27
10 com.apple.speech.synthesis.MacinTalkSynthesizer 0x07b3b079 MTMBChangeAmplitude::NextSegment(MTMBSegment*) + 35
11 com.apple.speech.synthesis.MacinTalkSynthesizer 0x07b6b403 non-virtual thunk to MTMBChangeAmplitude::NextSegment(MTMBSegment*) + 27
12 com.apple.speech.synthesis.MacinTalkSynthesizer 0x07b3ac71 MTMBSpeechRateModifier::NextSegment(MTMBSegment*) + 211
13 com.apple.speech.synthesis.MacinTalkSynthesizer 0x07b6b5fe non-virtual thunk to MTMBSpeechRateModifier::NextSegment(MTMBSegment*) + 27
14 com.apple.speech.synthesis.MacinTalkSynthesizer 0x07b3aa15 MTBEPhraseProcessor::GenerateSamples(MTBESoundOutput*, int*) + 277
15 com.apple.speech.synthesis.MacinTalkSynthesizer 0x07b2b52f MT3BEngineTask::Execute(void*) + 337
16 com.apple.speech.synthesis.MacinTalkSynthesizer 0x07b06cce MTBEWorker::ExecuteTasks() + 384
(0013906)
Echelon9   
2012-08-14 10:16   
A more recent patch version is attached (macspeech3.patch)
(0015977)
chief1983   
2014-06-30 18:18   
Checked back up on this patch. Only takes two line additions of FS2_SPEECH to the Xcode project now I think, both added below the only two occurences of APPLE_APP. Ran it, no speech. fs2_open.ini in ~/Library/FS2_Open looks like:

[Default]
VideocardFs2open=OGL -(1024x768)x32 bit
TextureFilter=1
OGL_AnisotropicFilter=0
OGL_AntiAliasSamples=0
SoundDeviceOAL=Built-in Output
CurrentJoystick=99999
EnableJoystickFF=0
EnableHitEffect=0
NetworkConnection=LAN
ConnectionSpeed=Fast
LastPlayer=chief_work
SpeechTechroom=1
SpeechBriefings=1
SpeechIngame=1
SpeechMulti=1
SpeechGame=1

[Sound]
PlaybackDevice=Built-in Output
CaptureDevice=Built-in Microphone

[PXO]
FS2OpenPXO=1


I added SpeechGame as I saw it in my Windows registry list as well. Debug build log looks like:

Initializing OpenAL...
  OpenAL Vendor : Apple Computer Inc.
  OpenAL Renderer : Software
  OpenAL Version : 1.1

  Found extension "AL_EXT_float32".

  Sample rate: 0 (44100)
  EFX enabled: NO
  Playback device: Built-in Output
  Capture device: Built-in Microphone
... OpenAL successfully initialized!
Why are you trying to free a NULL pointer? [fsmemory.cpp(19)]
Why are you trying to free a NULL pointer? [fsmemory.cpp(19)]
Why are you trying to free a NULL pointer? [fsmemory.cpp(19)]
Why are you trying to free a NULL pointer? [fsmemory.cpp(19)]
STUB: speech_set_voice in /Users/cliff.gordon/fs2open/code/sound/speech.cpp at line 280, thread 63763

-query_speech doesn't seem to change anything for me.
(0015978)
chief1983   
2014-06-30 18:21   
(Last edited: 2014-06-30 18:22)
I've uploaded a new patch version with tweaked project files. I also added the FS2_SPEECH define to configure.ac, however that file doesn't affect Xcode to my knowledge. That also made me wonder how ApplicationServices is being loaded into the Xcode builds then, or if it was needed at all. This doesn't fix it, it's just a more up to date starting point for anyone looking at it.

(0015981)
Echelon9   
2014-06-30 20:26   
Thanks, I'll take another look at the memory corruption here. Looks like another double free.
(0016000)
Echelon9   
2014-07-01 08:08   
You shouldn't need to set SpeechGame=1, see further the table of speech types in the array FSSpeech_play_id[] in fsspeech.cpp
(0016002)
chief1983   
2014-07-01 09:57   
Well, I wasn't sure, but removing it doesn't change anything. I don't get any crashes, I just enter the tech room, and I don't hear any TTS.
(0016003)
Echelon9   
2014-07-01 10:11   
Same here. I spent some time testing and debugging this evening.

Whilst no crashes, also no spoken words on 10.9. I can confirm the text is being passed to the SpeakCFString() API call, just nothing happens after that.
(0016004)
chief1983   
2014-07-01 10:36   
Like I said, I wonder if that's because the ApplicationServices framework isn't actually being added as an App resource in the Xcode4 project. It was added to configure.ac for some reason but that has nothing to do with Xcode builds. But I would probably expect more warnings/errors if that were actually the problem.

(0016005)
Echelon9   
2014-07-01 11:09   
I did a quick test with otool -L on the resultant binary, and it looks like ApplicationServices.framework was linked in.
(0016654)
chief1983   
2015-04-23 11:16   
So any other thoughts on this? If the framework is linked in, why is there no speech? Something needs to be configured in System Preferences or something?
(0016655)
chief1983   
2015-04-23 13:06   
(Last edited: 2015-04-23 13:09)
I applied the macspeech4.patch to current trunk and tried again, after adjusting some settings in the VoiceOver configuration. Also tried the -query_speech flag. No voice in tech room, nothing from query_speech either.

Edit: Attached an updated version of the patch with the chunks in the right places and some whitespace goofs fixed.

(0016657)
chief1983   
2015-04-23 13:39   
Log excerpt:

... OpenAL successfully initialized!
Why are you trying to free a NULL pointer? [fsmemory.cpp(19)]
Why are you trying to free a NULL pointer? [fsmemory.cpp(19)]
Why are you trying to free a NULL pointer? [fsmemory.cpp(19)]
Why are you trying to free a NULL pointer? [fsmemory.cpp(19)]
STUB: speech_set_voice in /Users/cliff.gordon/fs2_open_git/code/sound/speech.cpp at line 280, thread 6729
Initializing OpenGL graphics device at 640x480 with 32-bit color...

Issue History
2012-04-13 00:20gereedyNew Issue
2012-04-13 00:20gereedyFile Added: macspeech.patch
2012-04-13 02:16niffiwanSeverityminor => feature
2012-04-13 15:54gereedyNote Added: 0013464
2012-04-13 15:54gereedyFile Added: macspeech2.patch
2012-04-23 09:53Echelon9Assigned To => Echelon9
2012-04-23 09:53Echelon9Statusnew => code review
2012-04-23 10:08Echelon9Note Added: 0013479
2012-04-30 00:26gereedyNote Added: 0013490
2012-04-30 11:30Echelon9Note Added: 0013492
2012-05-03 23:00gereedyNote Added: 0013515
2012-05-09 15:07chief1983Note Added: 0013530
2012-08-14 09:51Echelon9Note Added: 0013905
2012-08-14 10:16Echelon9File Added: macspeech3.patch
2012-08-14 10:16Echelon9Note Added: 0013906
2014-06-30 18:18chief1983Note Added: 0015977
2014-06-30 18:20chief1983File Added: macspeech4.patch
2014-06-30 18:21chief1983Note Added: 0015978
2014-06-30 18:22chief1983Note Edited: 0015978bug_revision_view_page.php?bugnote_id=15978#r846
2014-06-30 20:26Echelon9Note Added: 0015981
2014-07-01 08:08Echelon9Note Added: 0016000
2014-07-01 09:57chief1983Note Added: 0016002
2014-07-01 10:11Echelon9Note Added: 0016003
2014-07-01 10:36chief1983Note Added: 0016004
2014-07-01 10:36chief1983Note Edited: 0016004bug_revision_view_page.php?bugnote_id=16004#r854
2014-07-01 11:09Echelon9Note Added: 0016005
2015-04-23 11:16chief1983Note Added: 0016654
2015-04-23 13:06chief1983Note Added: 0016655
2015-04-23 13:09chief1983File Added: macspeech5.patch
2015-04-23 13:09chief1983Note Edited: 0016655bug_revision_view_page.php?bugnote_id=16655#r1040
2015-04-23 13:39chief1983Note Added: 0016657