BanglaSpeech2Text: An open-source offline speech-to-text package for Bangla language. Fine-tuned on the latest whisper speech to text model for optimal performance.
Project description
Bangla Speech to Text
BanglaSpeech2Text: An open-source offline speech-to-text package for Bangla language. Fine-tuned on the latest whisper speech to text model for optimal performance. Transcribe speech to text, convert voice to text and perform speech recognition in python with ease, even without internet connection.
Installation
pip install banglaspeech2text
Models
Model | Size | Best(WER) |
---|---|---|
'tiny' | 100-200 MB | N/A |
'base' | 200-300 MB | 46 |
'small' | 900-1000 MB | 18 |
NOTE: "Bigger model have better accuracy but slower inference speed. Smaller wer is better." NOTE: You can view the models from here
Usage
Download a model
from banglaspeech2text import Model, available_models
# Download a model
models = available_models()
print(models) # see the available models by diffrent people and diffrent sizes
model = models[0] # select a model
model.download() # download the model
Use with file
from banglaspeech2text import Model, available_models
# Load a model
models = available_models()
model = models[0] # select a model
model = Model(model) # load the model
model.load()
# Use with file
file_name = 'test.wav'
output = model.recognize(file_name)
print(output) # output will be a dict containing text
print(output['text'])
Use with SpeechRecognition
import speech_recognition as sr
from banglaspeech2text import Model, available_models
# Load a model
models = available_models()
model = models[0] # select a model
model = Model(model) # load the model
model.load()
r = sr.Recognizer()
with sr.Microphone() as source:
print("Say something!")
audio = r.listen(source)
output = model.recognize(audio)
print(output) # output will be a dict containing text
print(output['text'])
Use GPU
import speech_recognition as sr
from banglaspeech2text import Model, available_models
# Load a model
models = available_models()
model = models[0] # select a model
model = Model(model,device="gpu") # load the model
model.load()
r = sr.Recognizer()
with sr.Microphone() as source:
print("Say something!")
audio = r.listen(source)
output = model.recognize(audio)
print(output) # output will be a dict containing text
print(output['text'])
NOTE: This package uses torch as backend. So, you can use any device supported by torch. For more information, see here. But you need to setup torch for gpu first from here.
Some Methods
from banglaspeech2text import Model, available_models
models = available_models()
print(models[0]) # get first model
print(models['base']) # get base models
print(models['whisper_base_bn_sifat']) # get model by name
# set download path
model = Model(model,download_path=r"F:\Code\Python\BanglaSpeech2Text\models")
model.load()
# directly load a model
model = Model('base')
model.load()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for BanglaSpeech2Text-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c2dd5f1af227dccb5632c5156a2b813ceb539f23baaa4fe5499b9c8c336a22d4 |
|
MD5 | b50827ada0611e8927e681685ba72ee4 |
|
BLAKE2b-256 | b1a6d2e9f2069dc4e4528b2bb2e99b56e28cc6948b7dc08cb24bdbcb5d3c1741 |