Skip to main content

A python wrapper for google speech to text api

Project description

easySpeech


GitHub issues GitHub forks GitHub stars GitHub license GitHub last commit GitHub contributors


easySpeech is an open source python wrapper for google speech to text api that doesn't require PyAaudio(So you specially windows user don't have to deal with the errors while installing PyAudio) and also works with hugging face transformers

Installation

You can install easySpeech very easily using the following command

pip3 install easySpeech

Usage

  • Using google speech to text api
    By default easySpeech comes with a default api key which you can for testing purposes using the following code.
from easySpeech import speech
a=speech.speech('google')
print(a)

For production purpose use your own key because google can revoke the default api key at any time. Get your own api key from http://www.chromium.org/developers/how-tos/api-keys and use the following code

from easySpeech import speech
a=speech.speech('google',key="your api key")
print(a)

Specifying the duration of speech recognition in seconds(default value is 5 seconds)

from easySpeech import speech
a=speech.speech('google',duration = 10)
print(a)

Specifying the sample frequency(default is 44100)

from easySpeech import speech
a=speech.speech('google',duration = 10,freq = 44100)
print(a)

Specifying the language(works only for google speech api and default is english)

from easySpeech import speech
a=speech.speech('google',language="en-US")
print(a)

Converting an audio file to text(Currently it supports only wav file)

from easySpeech.recognize import *
r = Recognizer()
recording = AudioFile('recording.wav')
with recording as source:
    audio = r.record(source)
text=r.recognize_google(audio,key=None, language="en-US", show_all=False)
  • Using hugging face transformers(works offline and no need of any kind of api key) For using easySpeech with hugging face transformers use the following code.
from easySpeech import speech
a=speech.speech('ml')
print(a)

Specifying the duration of speech recognition in seconds(default valus is 5 seconds)

from easySpeech import speech
a=speech.speech('ml',duration = 10)
print(a)

Specifying the sample frequency(default is 44100)

from easySpeech import speech
a=speech.speech('ml',duration = 10,freq = 44100)
print(a)

Converting an audio file to text(Currently it supports only wav file)

from easySpeech import ml
a=ml.ml('recording.wav')
print(a)
  • Recording audio
    For recording audio use the following code
from easySpeech import record
import sounddevice as sd
freq = 44100
duration = 5
recording = sd.rec(int(duration * freq), 
                    samplerate=freq, channels=2)

record.write("recording.wav", recording, freq, sampwidth=2)

How to contribute

Since it is a free software , you can contribute to make it better. New contributors are always welcome, whether you write code, create resources, report bugs, or suggest features.

The easySpeech is written primarily in Python3x

Have a look at the open issues to find a mission that resonates with you.


Contact

Email: saptakbhoumik@gmail.com
If you find any bug make a issue immediately.

License

easySpeech is lisenced under MIT license

MIT License | Copyright (c) 2021 SaptakBhoumik

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

easySpeech-1.tar.gz (1.8 MB view details)

Uploaded Source

File details

Details for the file easySpeech-1.tar.gz.

File metadata

  • Download URL: easySpeech-1.tar.gz
  • Upload date:
  • Size: 1.8 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.4.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.55.0 CPython/3.8.2

File hashes

Hashes for easySpeech-1.tar.gz
Algorithm Hash digest
SHA256 917cf83d88d3cbdf9118b47d3a148e38e8d4a3c57f91c54ffd6ab04e4051b294
MD5 ebf6b426a2371151304cf4e7e1a6a80b
BLAKE2b-256 5a539b9cad542ed59346afcc4a480bfb104ad17e2588de448825a474ef7694ab

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page