[Solved] Comparing two text variables issue!

I’m trying to do a very simple task, Speech Recognizer block would be used to identify a word , I’m saving the output of the block and comparing it with another variable has the matched word
the problem is that everything goes well if and only if language is English else or i will be more clear when making language to Arabic the comparison of two really matched variables is set to FALSE !!
i made a debug label to see if the output is really the same word and found that it’s really the same word but comparison result still false !
how to solve this problem ??
Thanks in advance.


Can you share a screenshot of you’re blocks you are using to accomplish the task?


It’s hard to tell because we can’t see your other blocks but here’s a question for you:

Are you meaning to compare stored VoiceLanguage with app Voice? Or are you supposed to be comparing app VoiceInput with app Voice?

And what do you have stored in app Voice?

Yes , the purpose is to compare the two variables.
VoiceInput is the spoken word
and app Voice is the word I’m comparing with
stored VoiceLanguage = ENGLISH
app Voice = “Hello”
app VoiceInput = “Hello”
Result or TestLabel = True

stored VoiceLanguage = ARABIC
app Voice = “تشغيل” ( Arabic Word )
app VoiceInput = “تشغيل” ( The same Arabic Word )
Result :

I added the debugging Text input to fill with the spoken word and the strange thing is that the word is 100% the same app voice word !

I noticed that Text block trim spaces doesn’t work in Arabic words too !

I noticed that the output of Speech Recognizer when language is ARABIC , length is increased by one !
so, if i got the length of a known text the result is correct , but when getting the length of the output of speech recognizer for the same known text the result is NOT the same !!


I believe this has been addressed in another post. Please search the forum before posting a new topic.

Your blocks are not correct. You need to check if app VoiceInput = app Voice.

Sorry , but this issue is completely different !

Oh ! that’s really a screenshot mistake i noticed this before but forgot to repost the screenshot my bad sorry .
but the problem still exist as i said before length of text is really increased by one !
notice that the problem occurs only in Arabic , in English there’s no problem !

It’s not a great solution but, if you know it’s always going to have an extra space on either side of the word, you could use a “text” command block to remove the space. I think that may work. It doesn’t solve the answer of why though.

1 Like

Actually as i said before, trimming spaces doesn’t worke also in Arabic text !

I solved the problem by :
1- getting the length of spoken text
2- make the new length = length - 1
3- compare using ( is Text contains of word && length == length of word )

It solved my problem but didn’t make me understand why that happened !!


What I would do is to join the text you are receiving from the voice recognition with two symbol characters so that you can see what is being added. For example, Set label text to join # + VoiceInput + #. That way, when you look at the label, you will see something like #Hello # and you’ll know that it’s adding a space to the end of the variable.


I added the text to input text and copied it to see if it’s changed the result is the word is 100% the same with no any extra characters and that’s the strangest thing !!

That is strange! Without seeing your blocks, it’s hard to know why that might be happening. Perhaps it’s just a bug with Arabic language processing?

1 Like

This project is available at Thunkable

I submitted a bug report at Arabic speech recognition returns incorrect string length · Issue #336 · thunkable/thunkable-issues · GitHub.

I was able to duplicate the problem you described. I had the speech recognition recognize شكرا لكم (shukraan lakum; thank you in English) and check the word length of the recognized word vs. the stored variable value شكرا لكم.

The length of the stored variable was 8 while the length of the recognized speech was 9.

So yeah, this doesn’t help you but at least duplicating it suggests there may be a bug or something for someone else to discover what is causing this.



Something else interesting is that when I compare the two text strings character by character, NONE of the characters are equal in the same location in both strings.

The following code returns ≠≠≠≠≠≠≠≠≠

Note that testing speech recognition from French to English results in equal length strings of 7 characters (Bonjour = Bonjour) and the code above returns =======

This might be relevant:

And this about UTF character counting.

Also, the section starting with “Extreme Grapheme Clusters” here.


Thanks a lot for your efforts @tatiang
Trimming spaces text block doesn’t work also in Arabic words .

1 Like