GithubHelp home page GithubHelp logo

t-vk / termux-deepspeech Goto Github PK

View Code? Open in Web Editor NEW
64.0 3.0 13.0 26 KB

Open source offline speech recognition for Android using Mozilla's DeepSpeech in Termux

Shell 100.00%
offline speech-recognition open-source android deepspeech mozilla termux bash

termux-deepspeech's Introduction

Open source offline speech recognition for Android using Mozilla's DeepSpeech in Termux

Requirements

  • ~3GB of disk space during installation; afterwards only ~2GB
  • Termux
  • Termux:API

Installation

  • Install the following (open source) apps: Termux, Termux:API
  • Open Termux and run pkg i -y git && git clone https://github.com/T-vK/Termux-DeepSpeech.git && cd ./Termux-DeepSpeech && ./speech2text

This will take a while beacuse it needs to download a pre-trained DeepSpeech model and a DeepSpeech release. It will probably also ask for microphone permissions (which are required for obvious reasons).

Usage

If the installation was successful, you should now be able to use command speech2text. speech2text will listen to your microphone for (by default) 2 seconds and then print the words that were recognized.

Advanced usage

You could create bash scripts like this:

#!/data/data/com.termux/files/usr/bin/bash

WORDS="$(speech2text)"                            # This will listen to the microphone for (by default) 2 seoncds and the write what you said in the variable WORDS

echo "Recognized: $WORDS"                         # Show what you just said

if [[ "$WORDS" =~ "light" ]]; then                # If what you said contained the word "light"
    if [[ $WORDS =~ "on" ]]; then                 # If what you said contained the word "on"
        termux-tts-speak "Turning flashlight on"  # Let a robot voice say "Turning flashlight on"
        termux-torch on                           # Turn the flashlight on
    elif [[ $WORDS =~ "of" ]]; then               # If what you said contained the word "of"
        termux-tts-speak "Turning flashlight off" # Let a robot voice say "Turning flashlight off"
        termux-torch off                          # Turn the flashlight off
    fi
elif [[ "$WORDS" =~ "heating" ]] || [[ "$WORDS" =~ "temperature" ]]; then   # If what you said contained the word "heating" or "temerature"
    # Do whatever here...
    echo "Hello"
else
    termux-tts-speak "You said: $WORDS"           # Let a robot voice repeat what it thought you said...
fi

If you install the Termux:Widget app and save the above script under "$HOME/.shortcuts/tasks/" and make it executable for example like this: chmod +x "$HOME/.shortcuts/tasks/speech-command" (speech-command is the name of the script). You can then then create a widget that triggers the script. Or using the app HomeBot (open source) you can remap long-pressing the home button which usually triggers the Google voice assistent to run your speech-command script.

Warning

This is a very new script that has barely been tested. You might also have to install a TTS Engine (Flite TTS Engine is a good open source one) because I'm using text-to-speech commands a few times in the Advanced usage example.

termux-deepspeech's People

Contributors

t-vk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

termux-deepspeech's Issues

Error "ffmpeg": cannot locate symbol "_ZNSt6..." on speech2text script execution

Hello,

First, thanks very much for this script creation, it's very interesting!

I have been able to solve the error, just i want to notify the proble and share the solution.

I have tryed to run, but i get the next error:


CANNOT LINK EXECUTABLE "ffmpeg": cannot locate symbol "_ZNSt6__ndk16__itoa8__u32toaEjPc" referenced by "/data/data/com.termux/files/usr/lib/libopenmpt.so"...
Unexpected type for ./tmp.wav: 0

The missing symbol should be supplied by the "libc+++_shared.so" library.
I have tryed preloading the lib from Termux lib dir before executing "speech2text" using the next command:


env LD_PRELOAD=/data/data/com.termux/files/usr/lib/libc++_shared.so ./Termux-DeepSpeech/speech2text

And now "speech2text" script runs fine.
So it seems that the libc++ version supplied by deepspeech is obsolete.

I have found two solutions:

  1. Set the LD_PRELOAD variable al the start of the "speech2text" script addinge the next line:
    LD_PRELOAD=/data/data/com.termux/files/usr/lib/libc++_shared.so
  2. Modify the script to update de lib in ".Termux-DeepSpeech/deepspeech-bin/" dir from the Termux one.

Thanks again.

Berbascum

Unexpected type for ./tmp.wav: 49152

Sometimes, speech2text throws this error. The number varies.

I found no way to reproduce it reliably. So before I go add some logging output lines to the entire script, maybe you know what it likely is, and can tell me to put logging at the right location(s), that show me some context when it happens).

(Btw, since it’s hard to test right now, giving me a hint on how to make it recognize German would make it much easier for me to test it. I think right now, it may struggle because it can’t find anything English with my accent. ;)

Recogniticon quality surprisingly bay?

I thought DeepSpeech was a NN-based good model.

I found no details regarding how well this works. I could not get it to recognize things correctly even one time.

The best recognition was also the most funny one: It turned “substance abuse is bad” into “substance the best”. 🤣

So this bug exists, as a request to add a link to the readme, where users can read about DeepSpeech. (And possibly download other speech files, as it may be my accent. 😇)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.