Page MenuHomePhabricator

Error message when preview empty transcription
Closed, ResolvedPublic1 Estimated Story Points

Description

If you leave the Transcritpion field empty and press the button 'preview' the user gets:

Could not generate preview

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Wikispeech usage</title> </head> <body> <h1>Wikispeech usage</h1> USAGE: /?lang=LANG&input=TEXT <br> <a href='http://speechoid-wikispeech-server-1:10000/options'>Wikispeech parameters (json)</a> <br> <br> Supported languages are: [&#39;sv&#39;, &#39;nb&#39;, &#39;en&#39;, &#39;ar&#39;] <p/> <b>EXAMPLES</b><br/> US English: <a href='http://speechoid-wikispeech-server-1:10000/?lang=en&input=A+test'>http://speechoid-wikispeech-server-1:10000/?lang=en&input=A test</a><br/> Swedish: <a href='http://speechoid-wikispeech-server-1:10000/?lang=sv&input=Vi%20testar%20talsyntes'>http://speechoid-wikispeech-server-1:10000/?lang=sv&input=Vi%20testar%20talsyntes</a><br/> Arabic: <a href='http://speechoid-wikispeech-server-1:10000/?lang=ar&input=السويد'>http://speechoid-wikispeech-server-1:10000/?lang=ar&input=السويد</a><br/> Basque: <a href='http://speechoid-wikispeech-server-1:10000/?lang=eu&input=Hau%20proba%20bat%20da'>http://speechoid-wikispeech-server-1:10000/?lang=eu&input=Hau%20proba%20bat%20da</a> (only works if an AhoTTS server is running) <hr> Other things to try: <br> <a href='http://speechoid-wikispeech-server-1:10000/languages'>http://speechoid-wikispeech-server-1:10000/languages</a> <br> <a href='http://speechoid-wikispeech-server-1:10000/default_voices'>http://speechoid-wikispeech-server-1:10000/default_voices</a> <hr> <a href='http://speechoid-wikispeech-server-1:10000/textprocessing'>Textprocessing parameters (json)</a> <br> <a href='http://speechoid-wikispeech-server-1:10000/textprocessing/languages'>http://speechoid-wikispeech-server-1:10000/textprocessing/languages</a> <br> <a href='http://speechoid-wikispeech-server-1:10000/textprocessing/textprocessors'>http://speechoid-wikispeech-server-1:10000/textprocessing/textprocessors</a> <br> <a href='http://speechoid-wikispeech-server-1:10000/textprocessing/textprocessors/en'>http://speechoid-wikispeech-server-1:10000/textprocessing/textprocessors/en</a> <hr> <br> <a href='http://speechoid-wikispeech-server-1:10000/synthesis'>Synthesis parameters (json)</a> <br> <a href='http://speechoid-wikispeech-server-1:10000/synthesis/languages'>http://speechoid-wikispeech-server-1:10000/synthesis/languages</a> <br> <a href='http://speechoid-wikispeech-server-1:10000/synthesis/voices'>http://speechoid-wikispeech-server-1:10000/synthesis/voices</a> <br> <a href='http://speechoid-wikispeech-server-1:10000/synthesis/voices/en'>http://speechoid-wikispeech-server-1:10000/synthesis/voices/en</a> <hr> Textprocessing examples: <br> <a href='http://speechoid-wikispeech-server-1:10000/textprocessing/?lang=en&input=A+test'>http://speechoid-wikispeech-server-1:10000/textprocessing/?lang=en&input=A test</a> <br> <a href='http://speechoid-wikispeech-server-1:10000/textprocessing/?lang=sv&input=Vi+testar+talsyntes'>http://speechoid-wikispeech-server-1:10000/textprocessing/?lang=sv&input=Vi testar talsyntes</a> <br> <a href='http://speechoid-wikispeech-server-1:10000/textprocessing/?lang=eu&input=Hau+proba+bat+da'>http://speechoid-wikispeech-server-1:10000/textprocessing/?lang=eu&input=Hau proba bat da</a> <p/> Tokenisation example: <br> <a href='http://speechoid-wikispeech-server-1:10000/textprocessing/?lang=en&input=A+test&textprocessor=basic_en&process=tokenise'>http://speechoid-wikispeech-server-1:10000/textprocessing/?lang=en&input=A test&textprocessor=basic_en&process=tokenise</a> <p/> Basic synthesis example: <br> <a href='http://speechoid-wikispeech-server-1:10000/?lang=en&input=A+test&textprocessor=basic_en&voice=cmu-slt-flite'>http://speechoid-wikispeech-server-1:10000/?lang=en&input=A+test&textprocessor=basic_en&voice=cmu-slt-flite</a> <hr> Other tests (experimental): <br> <a href='http://speechoid-wikispeech-server-1:10000/test.html'>http://speechoid-wikispeech-server-1:10000/test.html</a> <br> <a href='http://speechoid-wikispeech-server-1:10000/workflow_demo/test.html'>http://speechoid-wikispeech-server-1:10000/workflow_demo/test/html</a> <address></address> <p/> <hr> <a href="/version">Wikispeech version info</a><br/> Server/URL: <a href=http://speechoid-wikispeech-server-1:10000/>http://speechoid-wikispeech-server-1:10000/</a> <br/> <!-- hhmts start -->Last modified: Fri Nov 17 16:23:15 GMT 2017 <!-- hhmts end --> </body> </html>

Event Timeline

I think understand what is happening.
The local and production environments behave differently because they use different endpoints:
Production uses the HAProxy queue (localhost:5000), which gives a generic "Unable to communicate" error on failure.
Local requests go directly to Speechoid (speechoid-wikispeech-server-1:10000), which returns an HTML usage page on invalid input.

So it's the same error, just shown differently depending on routing.

Maybe we could make the error message a bit clearer for the user?

Right now we just show

result.error.info

but it might be helpful to add a short explanation about why the error occurred. For example, if the transcription input is invalid or Speechoid can't handle the request, we could show something like:

"Could not generate preview. The transcription might be invalid or the speech server is unreachable."

So they don't only get the error with the postData

( 'postData' => array ( 'lang' => 'sv', 'voice' => 'stts_sv_nst-hsmm', 'input' => 'tɑːlɑrˌɛn', 'input_type' => 'ipa', ), )

It could be an alternative in ext.wikispeech.transcriptionPreviewer.js to add:

self.$player.attr( 'src', '' );
		mw.log.error( 'Failed to synthesize:', code, result );
		const message = {
			result: result.error.info,
			message: "The transcription might be invalid or the speech server is unreachable."
		};
		const $content = $( '<div>' )
		.append( $( '<p>' ).text( message.message ) )
		.append( $('<p>').text('Information:\n') )
		.append( $( '<pre>' ).text( message.result ) );
		const title = mw.msg( 'wikispeech-error-generate-preview-title' );
		OO.ui.alert( $content, { title: title, size: 'medium' } );

Something is definitely different between the producer wiki and local. On the latter I get this when adding a phoneme outside the symbol set:

Could not generate preview

ERROR: failed mapping transcription : found unknown phonemes in transcription /ˈ̀ɑː.pA/: [A]

That also matches what we have in the end user documentation.

To fix the issue with the empty transcription we could probably just disable the preview button when the field is empty. And make sure we don't send empty requests if you somehow manage to get around that.

Turns out that this is caused by Sox proxy. If you use it locally you get the same result. That's what port 5000 is about.

Sox proxy is a bit of a hack for MaryTTS and has had similar issues in the past (see T331308). I don't think it's worth spending time on fixing this, assuming that we will drop MaryTTS in favour of Matcha.

I see, so no meaning in disable the preview button when the field is empty either?

Making sure we don't send any empty requests is still relevant. That's a different issue. Even if you don't use Sox proxy you get the HTML for the start page when you try to preview an empty transcription.

This should be fixed in SpeechoidConnector so that it won't make empty requests. If someone tries to there should probably be an API error that the frontend can display a message for. Disabling the button I'd say is extra and may not be that straight forward, see T308863.

Viktoria_Hillerud_WMSE renamed this task from Preview button in lexicon editor generates unexpected error to Error message when preview empty transcription.Aug 7 2025, 12:59 PM
Viktoria_Hillerud_WMSE set the point value for this task to 8.

This task is only for making sure that empty transcription isn't entered.

I removed that bits about errors when transcription isn't empty and created T402387: Sox proxy overwrites error messages.

Making sure we don't send any empty requests is still relevant. That's a different issue. Even if you don't use Sox proxy you get the HTML for the start page when you try to preview an empty transcription.

This should be fixed in SpeechoidConnector so that it won't make empty requests. If someone tries to there should probably be an API error that the frontend can display a message for. Disabling the button I'd say is extra and may not be that straight forward, see T308863.

Couldn't this alsp be fixed in SpecialEditLexicon.php to just say to a user that this field can't be empty?

It could.

If you add it to the connector it will also stop any other cases where an empty request is made. It would make it more robust. That said if it's too much work we can save that for another task.

Change #1182821 had a related patch set uploaded (by Viktoria Hillerud WMSE; author: Viktoria Hillerud WMSE):

[mediawiki/extensions/Wikispeech@master] Do not preview empty transcription

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

Viktoria_Hillerud_WMSE changed the point value for this task from 8 to 2.Sep 9 2025, 8:12 AM
Viktoria_Hillerud_WMSE changed the point value for this task from 2 to 1.Oct 15 2025, 9:16 AM

I think the message should used when the user sees it. At the moment it's generated in the connector instead. This means that if the input is empty for any other reason, you will also have a message talking about transcriptions, which may not make sense.

I think the quick fix would be to just do it in the frontend. I.e. if the field is empty show the messages. That would fix this particular error. A more general solution would probably require custom exceptions that lead to specific errors in the listen API. Finally there would be a check for them that triggers the error message.

I think the message should used when the user sees it. At the moment it's generated in the connector instead. This means that if the input is empty for any other reason, you will also have a message talking about transcriptions, which may not make sense.

I think the quick fix would be to just do it in the frontend. I.e. if the field is empty show the messages. That would fix this particular error. A more general solution would probably require custom exceptions that lead to specific errors in the listen API. Finally there would be a check for them that triggers the error message.

Ah, I had this solution in mind before, but then I changed it to be handled by the speechoid connector since your comment about it, but maybe I misunderstood it then?:

It could.

If you add it to the connector it will also stop any other cases where an empty request is made. It would make it more robust. That said if it's too much work we can save that for another task.

Since the preview button is broken, I think I have to solve that first in task: T406559, before moving on with this task.

Now it is implemented in frontend instead

Change #1182821 merged by jenkins-bot:

[mediawiki/extensions/Wikispeech@master] Do not preview empty transcription

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