Skip to content

Commit

Permalink
Fix speaker position for the AI generated voice
Browse files Browse the repository at this point in the history
  • Loading branch information
kubk committed May 10, 2024
1 parent a2d5071 commit 64686a0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
18 changes: 13 additions & 5 deletions src/screens/deck-review/store/card-preview-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,23 +114,31 @@ export class CardPreviewStore implements LimitedCardUnderReviewStore {
speak(removeAllTags(text), this.deckSpeakLocale);
}

isCardSpeakerVisible(type: DeckSpeakFieldEnum) {

isCardSpeakerVisible(type: "front" | "back") {
if (!userStore.isSpeakingCardsEnabled) {
return false;
}

if (this.voice) {
return type === "back";
return this.isOpened && type === this.deckSpeakField;
}

return (
isSpeechSynthesisSupported &&
this.isOpened &&
type === this.deckSpeakField &&
userStore.isSpeakingCardsEnabled
type === this.deckSpeakField
);
}

get canSpeak() {
if (this.voice) {
return true;
}

if (!isSpeechSynthesisSupported) {
return false;
}
return Boolean(this.voice || (this.deckSpeakLocale && this.deckSpeakField));
return Boolean(this.deckSpeakLocale && this.deckSpeakField);
}
}
15 changes: 11 additions & 4 deletions src/screens/deck-review/store/card-under-review-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,22 +116,29 @@ export class CardUnderReviewStore {
}

isCardSpeakerVisible(type: "front" | "back") {
if (!userStore.isSpeakingCardsEnabled) {
return false;
}

if (this.voice) {
return type === "back";
return this.isOpened && type === this.deckSpeakField;
}

return (
isSpeechSynthesisSupported &&
this.isOpened &&
type === this.deckSpeakField &&
userStore.isSpeakingCardsEnabled
type === this.deckSpeakField
);
}

get canSpeak() {
if (this.voice) {
return true;
}

if (!isSpeechSynthesisSupported) {
return false;
}
return Boolean(this.voice || (this.deckSpeakLocale && this.deckSpeakField));
return Boolean(this.deckSpeakLocale && this.deckSpeakField);
}
}

0 comments on commit 64686a0

Please sign in to comment.