Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(17)

Unified Diff: tts_service.cc

Issue 6299025: dmazzoni's fixes to ALSA for speech_synthesis (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/speech_synthesis.git@master
Patch Set: Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « linux/audio_output_alsa.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
}
« no previous file with comments | « linux/audio_output_alsa.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698