shhossain commited on
Commit
4ffe2fb
1 Parent(s): e29c19d

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +55 -21
README.md CHANGED
@@ -13,52 +13,86 @@ pipeline_tag: automatic-speech-recognition
13
  ## Results
14
  - WER 46
15
 
16
- # Use with banglaSpeech2text
17
 
18
- ## Test in google colab
19
- - [NoteBook](https://colab.research.google.com/drive/1rj4Jme6qrc8tRaPY3MTuuUc6MEr8We9N?usp=sharing)
20
 
21
  ## Installation
 
 
22
  ```bash
23
  pip install banglaspeech2text
24
  ```
25
- __Note__: Must have git and git lfs installed. For more info visit banglaspeech2text doc [here](https://github.com/shhossain/BanglaSpeech2Text#download-git)
26
-
27
 
28
  ## Usage
 
 
29
 
30
- ### Use with file
31
  ```python
32
- from banglaspeech2text import Model
33
 
34
- base_model = Model('whisper_base_bn_sifat')
35
- base_model.load() # loading the pipline. first time loading will take time as the model is not downloaded yet.
36
 
37
- audio_file = "test.wav" # .wav, .mp3, mp4, .ogg, etc.
 
 
38
 
39
- print(base_model.recognize(audio_file))
 
40
 
 
 
 
41
  ```
 
42
  ### Use with SpeechRecognition
 
43
  ```python
44
  import speech_recognition as sr
45
- from banglaspeech2text import Model, available_models
46
-
47
- # Load a model
48
- models = available_models()
49
- model = models[0] # select a model
50
- model = Model(model) # load the model
51
- model.load()
52
 
 
53
 
54
  r = sr.Recognizer()
55
  with sr.Microphone() as source:
56
  print("Say something!")
57
  audio = r.listen(source)
58
- output = model.recognize(audio)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
59
 
60
- print(output) # output will be a direct containing text
61
- print(output['text'])
 
 
 
62
  ```
63
 
64
  __Note__: For more usecases and models -> [BanglaSpeech2Text](https://github.com/shhossain/BanglaSpeech2Text)
 
13
  ## Results
14
  - WER 46
15
 
16
+ # Use with BanglaSpeech2text
17
 
18
+ ## Test it in Google Colab
19
+ - [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/shhossain/BanglaSpeech2Text/blob/main/BanglaSpeech2Text_in_Colab.ipynb)
20
 
21
  ## Installation
22
+ You can install the library using pip:
23
+
24
  ```bash
25
  pip install banglaspeech2text
26
  ```
 
 
27
 
28
  ## Usage
29
+ ### Model Initialization
30
+ To use the library, you need to initialize the Speech2Text class with the desired model. By default, it uses the "base" model, but you can choose from different pre-trained models: "tiny", "small", "medium", "base", or "large". Here's an example:
31
 
 
32
  ```python
33
+ from banglaspeech2text import Speech2Text
34
 
35
+ stt = Speech2Text(model="base")
 
36
 
37
+ # You can use it wihout specifying model name (default model is "base")
38
+ stt = Speech2Text()
39
+ ```
40
 
41
+ ### Transcribing Audio Files
42
+ You can transcribe an audio file by calling the transcribe method and passing the path to the audio file. It will return the transcribed text as a string. Here's an example:
43
 
44
+ ```python
45
+ transcription = stt.transcribe("audio.wav")
46
+ print(transcription)
47
  ```
48
+
49
  ### Use with SpeechRecognition
50
+ You can use [SpeechRecognition](https://pypi.org/project/SpeechRecognition/) package to get audio from microphone and transcribe it. Here's an example:
51
  ```python
52
  import speech_recognition as sr
53
+ from banglaspeech2text import Speech2Text
 
 
 
 
 
 
54
 
55
+ stt = Speech2Text(model="base")
56
 
57
  r = sr.Recognizer()
58
  with sr.Microphone() as source:
59
  print("Say something!")
60
  audio = r.listen(source)
61
+ output = stt.recognize(audio)
62
+
63
+ print(output)
64
+ ```
65
+
66
+ ### Use GPU
67
+ You can use GPU for faster inference. Here's an example:
68
+ ```python
69
+
70
+ stt = Speech2Text(model="base",use_gpu=True)
71
+
72
+ ```
73
+ ### Advanced GPU Usage
74
+ For more advanced GPU usage you can use `device` or `device_map` parameter. Here's an example:
75
+ ```python
76
+ stt = Speech2Text(model="base",device="cuda:0")
77
+ ```
78
+ ```python
79
+ stt = Speech2Text(model="base",device_map="auto")
80
+ ```
81
+ __NOTE__: Read more about [Pytorch Device](https://pytorch.org/docs/stable/tensor_attributes.html#torch.torch.device)
82
+
83
+ ### Instantly Check with gradio
84
+ You can instantly check the model with gradio. Here's an example:
85
+ ```python
86
+ from banglaspeech2text import Speech2Text, available_models
87
+ import gradio as gr
88
+
89
+ stt = Speech2Text(model="base",use_gpu=True)
90
 
91
+ # You can also open the url and check it in mobile
92
+ gr.Interface(
93
+ fn=stt.transcribe,
94
+ inputs=gr.Audio(source="microphone", type="filepath"),
95
+ outputs="text").launch(share=True)
96
  ```
97
 
98
  __Note__: For more usecases and models -> [BanglaSpeech2Text](https://github.com/shhossain/BanglaSpeech2Text)