Page MenuHomePhabricator

Move voice and language logic from frontend to backend
Open, Needs TriagePublic

Description

Currently voice and language are passed from the frontend to the WikispeechListenApi.

It should however be possible to set these inside the WikispeechListenApi instead. In addition to simplifying the API calls this should also be beneficial for e.g. T164252

Note that we still want to require voice and language in the case where revisionId is not provided. Also lang will be needed whenever a voice is provided to the api (to validate it)

Event Timeline

In includes/ApiWikispeechListen.php:getResponseForRevisionAndSegment() the following should work if added just before the call to the Segmenter.

Voice should be accessible through something like

$contentLanguage = $title->getPageLanguage();
$voiceKey = 'wikispeechVoice' . ucfirst( $contentLanguage );
$voice = MediaWikiServices::getInstance()
	->getUserOptionsLookup()
	->getOption( $context->getUserObj();, $voiceKey );

Note that validateParameters() would need to be updated (language is required if voice is provided and both are needed if revisionId is missing). getAllowedParams() would need to be changed to make language optional.

Licking this cookie as a slow burn task to work on

Change 626350 had a related patch set uploaded (by Lokal Profil; owner: Lokal Profil):
[mediawiki/extensions/Wikispeech@master] [WIP] Break out language and voice validation

https://gerrit.wikimedia.org/r/626350

While this could be useful, removing the parameters could cause issues for consumer wikis.