-
-
Notifications
You must be signed in to change notification settings - Fork 113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat: Added speed control option for Text-to-Speech module #1317
base: main
Are you sure you want to change the base?
Conversation
06e0d55
to
6688ec8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@heropj Thank you again very much for this PR. To me it works fine, but could you please save in the preferences (beside the chosen voice) the speed, so the user does not have always to change back the TTS speed to his prefered speed?
@@ -54,6 +58,16 @@ void TextToSpeechBar::setLocale(const QLocale& locale) | |||
} | |||
} | |||
|
|||
void TextToSpeechBar::setupSpeedOptionsComboBox() | |||
{ | |||
ui->speedLabel->setText(gt("speed")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you forgot to include the change to resources/i18n/en.json
. Please also don't forget to update resources/i18n/qqq.json
too.
src/texttospeechbar.cpp
Outdated
ui->speedComboBox->setMaxVisibleItems(10); | ||
ui->speedComboBox->setLineEdit(new ComboBoxLineEdit(ui->speedComboBox)); | ||
|
||
QStringList speedOptions = {"0.25x","0.50x","0.75x","1.00x","1.25x","1.50x","1.75x","2.00x"}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we include x in the speed rate value? Won't internationalization be slightly affected? In youtube there is no x.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍👍i'll remove it.
hello @kelson42 , @veloman-yunkan do we need a shortcut for choosing speed also?? if yes then what should be the key-combination.. |
6688ec8
to
af93a92
Compare
@heropj Ready for a new review? |
@kelson42 yes👍👍 |
src/texttospeechbar.cpp
Outdated
//keyboard shortcuts to control speed of tts | ||
QAction* increaseSpeedAction = new QAction(this); | ||
increaseSpeedAction->setShortcut(QKeySequence("Shift+.")); | ||
connect(increaseSpeedAction, &QAction::triggered, this, &TextToSpeechBar::increaseSpeed); | ||
|
||
QAction* decreaseSpeedAction = new QAction(this); | ||
decreaseSpeedAction->setShortcut(QKeySequence("Shift+,")); | ||
connect(decreaseSpeedAction, &QAction::triggered, this, &TextToSpeechBar::decreaseSpeed); | ||
|
||
this->addAction(increaseSpeedAction); | ||
this->addAction(decreaseSpeedAction); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Fix indentation
- Shouldn't at least some of this code be moved to
kiwixapp.cpp
(seeToggleTTSLanguageAction
as an example)?
src/texttospeechbar.cpp
Outdated
|
||
//keyboard shortcuts to control speed of tts | ||
QAction* increaseSpeedAction = new QAction(this); | ||
increaseSpeedAction->setShortcut(QKeySequence("Shift+.")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why "Shift+."
rather than ">"
? Same for the decrease speed action shortcut.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shift+. is clearer for users?? it's clear that they have to press shift and .
while for '>' they might get confused..??
in description of this PR i wrote "shift + >/<"
as keyboard shortcut for speed control, that was wrong..i have edited it to "shift + ./,"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The question is whether you want the shortcut to be bound to the "Shift + ."
key sequence (which is equivalent to ">"
on my keyboard but may resolve to something else on different keyboard layouts)¹? Or the underlying reason for selecting this key combination is mnemonics - increase with ">" and decrease with "<"?
¹ BTW, what if there is a keyboard layout where "."
itself has to be entered via a Shift
key?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay..i got it.., we should go with mnemonics... i'll change it to '>' for speed up and '<' for speed down.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/texttospeechbar.cpp
Outdated
void TextToSpeechBar::resetSpeedComboBox() | ||
{ | ||
double savedSpeed = KiwixApp::instance()->getSavedTtsSpeed(m_speech.locale().name()); | ||
int index = (savedSpeed == 1.0) ? 3 : (savedSpeed - 0.25) * 4; //default speed: 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is the special handling of the savedSpeed == 1.0
case needed? Don't you trust the (savedSpeed - 0.25) * 4
formula always working correctly?
src/texttospeechbar.cpp
Outdated
int currentIndex = ui->speedComboBox->currentIndex(); | ||
if (currentIndex < ui->speedComboBox->count() - 1) { | ||
ui->speedComboBox->setCurrentIndex(currentIndex + 1); | ||
onSpeedChanged(currentIndex + 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Won't ui->speedComboBox->setCurrentIndex()
result in onSpeedChanged()
being called automatically due to the correctly set up signal handling? Same for decreaseSpeed()
c749921
to
afced9b
Compare
resources/i18n/en.json
Outdated
"increase-tts-speed": "Represents the action of increasing the speed of the text-to-speech.", | ||
"decrease-tts-speed": "Represents the action of decreasing the speed of the text-to-speech." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Wrong text (copied from
qqq.json
). Replace with text that should appear in the UI. - Fix indentation (eliminate the tab-vs-spaces discrepancy)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indentation was not fixed (see the diff in github)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file uses tabs instead of spaces whereas your editor likely inserts spaces.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file uses tabs instead of spaces whereas your editor likely inserts spaces.
Actually, it was the other way around (I absent-mindedly checked in libkiwix
instead of kiwix-desktop
), but you fixed it correctly. Thanks!
afced9b
to
a01ed1e
Compare
a01ed1e
to
2f7c966
Compare
fix #1299
>
/<
to increase/decrease speed.