
if service.click({
{"%Direct swipe right",
"%Go back",
}
})
return true
end
-- Import necessary modules for Android speech recognition and text manipulation
require "import"
import "android.speech.RecognizerIntent"
import "android.speech.SpeechRecognizer"
import "android.speech.RecognitionListener"
import "com.androlua.*"
import "android.net.Uri"
import "android.content.Intent"
import "java.util.Locale"

-- Define a variable to store the spoken words
local spokenText = ""

-- Function to store recognized words
function saveWords(words)
    spokenText = words
end

-- Function to start listening for speech input
function startListening()
    local verbalizationDetected = false

    -- Check if EditText node is available
    local node = service.getEditText()
    if node == nil then
        -- If no EditText node is present, send a message
        print("No text box is present.")
        return false
    end

    -- Create a new intent for speech recognition
    local recognizerIntent = Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH)
    recognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM)
    recognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, "hi-IN") -- Set the language to Hindi (hi-IN)
    recognizerIntent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE, this.getPackageName())

    -- Create a speech recognizer instance
    local speechRecognizer = SpeechRecognizer.createSpeechRecognizer(this)

    -- Define a recognition listener for speech events
    local speechListener = RecognitionListener{
        onResults = function(results)
            local data = results.getParcelableArrayList(SpeechRecognizer.RESULTS_RECOGNITION)
            if data ~= nil and data.size() > 0 then
                verbalizationDetected = true
                local recognizedText = data.get(0)

                -- Save the recognized words
                saveWords(recognizedText)

                -- Get the EditText node
                local editText = service.getText(node)

                -- Insert recognized words into the EditText node
                service.insertText(node, recognizedText .. " ")
            end

            -- If no verbalization detected, stop listening
            if not verbalizationDetected then
                kill()
                return false
            end
        end,
        onError = function()
            -- If an error occurs, stop listening
            kill()
            return false
        end
    }

    -- Set the recognition listener for the speech recognizer
    speechRecognizer.setRecognitionListener(speechListener)
    -- Start listening for speech input
    speechRecognizer.startListening(recognizerIntent)
end

-- Call the function to start listening for speech input
startListening()
-- Return true to indicate successful execution
return true