Use std::clamp from c++17 to set rate and pitch TTS Linux parameters
Change-Id: Ibbb32f914a3ae96a66bd2367f89f80e0d105c993 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5819581 Reviewed-by: Evan Liu <evliu@google.com> Reviewed-by: Katie Dektar <katie@chromium.org> Reviewed-by: David Tseng <dtseng@chromium.org> Commit-Queue: Bo Liu <boliu@chromium.org> Cr-Commit-Position: refs/heads/main@{#1348398}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
72eff02809
commit
af469ec1d7
1
AUTHORS
1
AUTHORS
@ -894,6 +894,7 @@ Malcolm Wang <malcolm.2.wang@gmail.com>
|
||||
Mallikarjuna Rao V <vm.arjun@samsung.com>
|
||||
Manish Chhajer <chhajer.m@samsung.com>
|
||||
Manish Jethani <m.jethani@eyeo.com>
|
||||
Manjunath Babu <10manju@gmail.com>
|
||||
Manojkumar Bhosale <manojkumar.bhosale@imgtec.com>
|
||||
Manuel Braun <thembrown@gmail.com>
|
||||
Manuel Lagana <manuel.lagana.dev@gmail.com>
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include <math.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
|
||||
@ -564,10 +565,8 @@ void TtsPlatformImplLinux::ProcessSpeech(
|
||||
DCHECK(BrowserThread::CurrentlyOn(content::BrowserThread::UI));
|
||||
|
||||
// Speech dispatcher's speech params are around 3x at either limit.
|
||||
float rate = params.rate > 3 ? 3 : params.rate;
|
||||
rate = params.rate < 0.334 ? 0.334 : rate;
|
||||
float pitch = params.pitch > 3 ? 3 : params.pitch;
|
||||
pitch = params.pitch < 0.334 ? 0.334 : pitch;
|
||||
float rate = std::clamp(static_cast<float>(params.rate), 0.334f, 3.0f);
|
||||
float pitch = std::clamp(static_cast<float>(params.pitch), 0.334f, 3.0f);
|
||||
|
||||
SPDChromeVoice matched_voice;
|
||||
auto it = voices_.find(voice.name);
|
||||
|
Reference in New Issue
Block a user