Code is Not Working as Intended- need help to figure out if I did something wrong

This is a picture of the block code I have.

This is a picture of what the screen look like before anything is done.

First, I will click on English to French, then I say something like "hello," and the sound "bonjour" plays back. All of that is what I want, but one of the two translation boxes is not working to how I want it. For the two boxes that say "translation," I want the top box to have the input written, and the bottom box to have the output. So If I click on "English to French," and say "hello," the top "Translation" box should say "hello," and the bottom one "bonjour." I think I have something wrong on here. Can someone help me please? Thanks.

Hello Raymond, welcome to the forum.

You are setting 'Label1' with both the French and English results. It is always best to give components meaningful names, for example 'Label_EnglishResult' 'Label_FrenchResult'.

In your Button Click Blocks, the language number should be set before the Speech Recognizer is called.

Hi, for Label1, I put it for both of them on purpose because it simply puts whatever I say/ my input. I changed the language number to before speech recognizer too, but I still just get "hello" and "hello" in both translation boxes when I translate from "English to French."

Can you re-name your Labels in the way I suggested so that we can follow your code?

https://www.professorcad.co.uk/appinventortips#TipsGui

But putting those labels as "Label_EnglishResult" wouldn't be accurate. When you click "English to French," and say something in english, the Label1 would have what I said in english written down. But when I click "French to English," and say something in french, the Label1 would have would I said in french. Hence, it's just putting down my input. With your suggestion I think I would have to change up the blocks, but I'm not sure what to do.

Not those names specifically, but names that are accurate.

I can set Label1 to "Input_Language," and Label2 to "Output_Translation" if that works?


with that change, my blocks look like this now

...but you should have two 'output' Labels?

Snap2

Let me change that real quick lol

Also, never 'lose' the type name of the component:

Label_OutputTranslation.

Ok


Here is what it looks like now

outputtranslation.text to translation

Sorry, I know you want me to remove the "set Label_OutputTranslation . Text," but I'm not sure what block just "translation" is

just read your code again, you will know where is the problem.

I should switch the "get translation" with the "SpeechRecognizer1"?

I changed it, but it still isn't working how I want it to.

Nevermind, it works! Thank you and ChrisWard so much for the help!!

1 Like