Skip to content
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

Fix / Download tts #1591

Merged
merged 3 commits into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions src/components/Settings/Language/Language.container.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,10 @@ export class LanguageContainer extends Component {
downloadingLangError: { ttsError: false, langError: false }
};

handleSubmit = async (optionalLang = null) => {
handleSubmit = async (optionalLang = null, isNewVoiceAvailable = false) => {
const { onLangChange } = this.props;
const selectedLang = optionalLang ? optionalLang : this.state.selectedLang;
onLangChange(selectedLang);
onLangChange(selectedLang, isNewVoiceAvailable);
this.initArasaacDB(selectedLang);
try {
await API.updateSettings({
Expand Down Expand Up @@ -196,17 +196,19 @@ export class LanguageContainer extends Component {
onDialogAcepted = downloadingLangData => {
const { marketId, lang, ttsName, continueOnline } = downloadingLangData;
this.setState({ openDialog: { open: false, downloadingLangData: {} } });
onAndroidPause(() => this.pauseCallback());
const downloadingLangState = {
isdownloading: true,
isDiferentTts: false,
engineName: ttsName,
marketId: marketId,
selectedLang: lang
selectedLang: lang,
firstClick: false,
continueOnline: false
};
this.props.setDownloadingLang(downloadingLangState);
if (continueOnline) this.handleSubmit(lang);
window.cordova.plugins.market.open(marketId);
navigator.app.exitApp();
};

onCloseDialog = () => {
Expand Down Expand Up @@ -462,7 +464,8 @@ export class LanguageContainer extends Component {
});
this.refreshLanguageList();
if (isDiferentTts) return;
await this.handleSubmit(selectedLang);
const isNewVoiceAvailable = true;
await this.handleSubmit(selectedLang, isNewVoiceAvailable);
showNotification(
<FormattedMessage {...messages.instaledLangSuccesNotification} />
);
Expand Down
5 changes: 3 additions & 2 deletions src/providers/LanguageProvider/LanguageProvider.actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ import {
} from './LanguageProvider.constants';
import { updateUserData } from '../../components/App/App.actions';

export function changeLang(lang) {
export function changeLang(lang, isNewVoiceAvailable = false) {
updateUserData();
return {
type: CHANGE_LANG,
lang
lang,
isNewVoiceAvailable
};
}

Expand Down
3 changes: 2 additions & 1 deletion src/providers/SpeechProvider/SpeechProvider.reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ function speechProviderReducer(state = initialState, action) {
options: {
...state.options,
voiceURI:
state.options.lang.substring(0, 2) !== action.lang.substring(0, 2)
state.options.lang.substring(0, 2) !==
action.lang.substring(0, 2) || action.isNewVoiceAvailable
? getVoiceURI(action.lang, state.voices)
: state.options.voiceURI,
lang:
Expand Down
7 changes: 5 additions & 2 deletions src/providers/SpeechProvider/tts.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,10 @@ const tts = {
if (!isAndroid()) {
return [];
} else {
const ttsEngs = synth.getEngines();
if (synth === undefined) {
synth = window.speechSynthesis;
}
const ttsEngs = synth.getEngines() || {};
return ttsEngs._list || [];
}
},
Expand All @@ -180,7 +183,7 @@ const tts = {
if (!isAndroid()) {
return;
} else {
const ttsDefaultEng = synth.getDefaultEngine();
const ttsDefaultEng = synth.getDefaultEngine() || {};
return ttsDefaultEng;
}
},
Expand Down