Index: tts_service.cc |
diff --git a/tts_service.cc b/tts_service.cc |
index bcb2c31db31d7b453cf2428e2e52746a8d245be7..9f83a2f3088b4eac1a4668052981d5babf0bb26d 100644 |
--- a/tts_service.cc |
+++ b/tts_service.cc |
@@ -192,9 +192,11 @@ void TtsService::Run() { |
continue; |
} |
- engine_->SetRate(current_utterance_->options->rate); |
- engine_->SetPitch(current_utterance_->options->pitch); |
- engine_->SetVolume(current_utterance_->options->volume); |
+ if (current_utterance_->options) { |
+ engine_->SetRate(current_utterance_->options->rate); |
+ engine_->SetPitch(current_utterance_->options->pitch); |
+ engine_->SetVolume(current_utterance_->options->volume); |
+ } |
// Synthesize the current utterance. The TTS engine will call our |
// callback method, Receive, repeatedly while it performs synthesis. |
@@ -216,14 +218,18 @@ void TtsService::Run() { |
engine_->SetReceiver(this); |
} |
+ // Save the utterance text because current_utterance_ is deleted |
+ // by the Done() callback before the call to SynthesizeText exits. |
+ string utterance_text = current_utterance_->text; |
+ |
engine_->SynthesizeText( |
- current_utterance_->text.c_str(), |
+ utterance_text.c_str(), |
audio_buffer_, |
audio_buffer_size_, |
&samples_output); |
// TODO(chaitanyag): Make the completion callback here. |
- LOG(INFO) << "Done: " << current_utterance_->text.c_str(); |
+ LOG(INFO) << "Done: " << utterance_text.c_str(); |
mutex_->Lock(); |
if (utterance_running_ == false) { |
@@ -281,6 +287,7 @@ tts_callback_status TtsService::Receive(int rate, |
bool success = ring_buffer_->Write(data, num_samples); |
if (!success) { |
+ LOG(INFO) << "Unable to write to ring buffer"; |
exit(0); |
} |