HABDroid VoiceCommand please help?

I’m using HABdroid ver 1.8.0.5 and here is my configuration (very simple)
.item:

String VoiceCommand

.rule:

rule "VoiceControl" 

when 
    Item VoiceCommand received command
then 
    val txt = VoiceCommand.state.toString.toLowerCase
    logInfo("Voice.Rec","VoiceCommand received "+txt)
  if(txt.contains("on")){
 Light_C_Staircase.sendCommand(ON)
}else if (command.contains("off")) {
            Light_C_Staircase.sendCommand(OFF)
        }
end

On HABDroid I click on micro symbol and start speaking, the system then pop up a little box which informs me the words I’ve just said. However the switch Light_C_Staircase doesn’t change at all. Please help me to fix this. It would be a great help!

Try it this way:

rule "VoiceControl" 

when 
    Item VoiceCommand received command
then 
    val txt = receivedCommand.toString.toLowerCase
    logInfo("Voice.Rec","VoiceCommand received "+txt)
		if (txt.contains("on") {
			Light_C_Staircase.sendCommand(ON)
		else if(txt.contains("off")) 
			Light_C_Staircase.sendCommand(OFF)
		}
end

yes it works thanks sihui, but there are still some problems:

  1. it looks like HABdroid use googleTTS service but mainly in my native language. Thus, in my rules file I create an if command to compare VoiceCommand value with the words from my language. For example:
if (txt.contains("khách")) {
			Light_C_Staircase.sendCommand(ON)
}

Then I said to Habdroid the word “khách” and the result of VoiceCommand item was perfectly show up.(I did this for debugging purpose:
Item:

String VoiceCommand "[%s]"

sitemap:

Text item=VoiceCommand

this makes things easier to observe because I only grab my android phone to play around with HABdroid, too lazy to use tail command on terminal screen :smile: )

However, my Light_C_Staircase switch doesn’t change to ON :frowning:
If you couldn’t solve the problem then I am very pleased to use HABDroid Voice controlling system which mainly based on English. Can you show me how to change it to use English as its native language?

2)Furthermore, some words which contains special character from my language can not typed in. I mean it does appear correctly when I am typing but after I save the rule file and open it again, several characters are change to “?”. I think it’s a error in font family, then I’ve tried many solutions from google but still no progress

Please help me @sihui

Which platform? Raspberry Pi? Then try:

Internationalisation options

Select Internationalisation Options and press Enter to be taken to a sub-menu containing the following options:

Change locale

Select a locale, for example en_GB.UTF-8 UTF-8.

1 Like

Hi I’m testing the voice command, but in the rule the software designer warns me of the error in parentheses {}
see attached video images Error Rules|666x500?
can you help me!
thank you

Post the error in text form … I hate watching any videos, sorry.

the error is in the Designer software
I do not know how to write

the attached file is an image file, not a video file

hello, following the rule I copied.

the number in the round parentheses indicates the righa in the Designer software

(11) rule “VoiceControl”
(12)
(13)when
(14) Item VoiceCommand received command
(15)then
(16) val txt = receivedCommand.toString.toLowerCase
(17) logInfo(“Voice.Rec”,"VoiceCommand received "+txt)
*(18) if (txt.contains(“on”) {
(19) Test_VOICE.sendCommand(ON)
*(20) else if(txt.contains(“off”))
*(21) Test_VOICE.sendCommand(OFF)
(22) }
(23)end

appear * of red color to the left of the righa 18/20/21
I carry the errors

(18) missing ‘)’ at ‘{’
(20) missing ‘}’ at ‘else’
(22)extraneous input ‘}’ expecting ‘end’


I solved this way …

I deleted parentheses {} and put the ( )

rule “VoiceControl”

when
Item VoiceCommand received command
then
val txt = receivedCommand.toString.toLowerCase
logInfo(“Voice.Rec”,"VoiceCommand received "+txt)
if (txt.contains(“on”))
Test_VOICE.sendCommand(ON)
else if(txt.contains(“off”))
Test_VOICE.sendCommand(OFF)
end

Good job, have fun.

Hello. I have tried voice command on the win xp and raspberry operating system and it works correctly.

Unfortunately the same program does not work on Win 7 operating system and other more raspberries.

How can I find the problem?
I remember being a beginner Thank you for your condolences

Take a look in your logs and watch for any errors: openhab.log, events.log.

I got a look at the logs: openhab.log, events.log.
they report many data …
I worked on the demo provided by the site …

Look for ERROR lines or any other strange entry.
Maybe you need to enable debug logging.

Today, I will do some tests, how to enable debugging.

If that is a question: just use the search button in this forum, you will find hundreds of answers.

I start the start_debug.bat file or start_debug.sh file according to the operating system, then I go to check the log files.
it’s correct?
thank you

Yes, or if you want to debug individual bindings you may do that through karaf console:

http://docs.openhab.org/administration/console.html

For example to debug the zwave binding you would enter:

log:set DEBUG org.openhab.binding.zwave and back to info level:
log:set INFO org.openhab.binding.zwave

thank you very much for information …
thank you … thank you very much