msis commited on
Commit
216357c
1 Parent(s): e9bc91d

Lastest model.

Browse files
.devcontainer/devcontainer.json ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // For format details, see https://aka.ms/vscode-remote/devcontainer.json or this file's README at:
2
+ // https://github.com/microsoft/vscode-dev-containers/tree/v0.202.3/containers/python-3
3
+ {
4
+ "name": "HF Spaces Demo",
5
+ "image": "nvcr.io/nvidia/nemo:22.03",
6
+ // Set *default* container specific settings.json values on container create.
7
+ "settings": {
8
+ "terminal.integrated.profiles.linux": {
9
+ "bash": {
10
+ "path": "/bin/bash"
11
+ }
12
+ },
13
+ "python.defaultInterpreterPath": "/opt/conda/bin/python",
14
+ "python.condaPath": "/opt/conda/bin/conda",
15
+ "python.languageServer": "Pylance"
16
+ },
17
+ // Add the IDs of extensions you want installed when the container is created.
18
+ "extensions": [
19
+ "ms-python.python",
20
+ "ms-python.vscode-pylance",
21
+ "github.vscode-pull-request-github",
22
+ "ms-toolsai.jupyter",
23
+ "ms-toolsai.jupyter-renderers",
24
+ "ms-vsliveshare.vsliveshare-pack"
25
+ ],
26
+ // docker run arguments
27
+ "runArgs": [
28
+ "--gpus=all",
29
+ "--ipc=host",
30
+ "--ulimit",
31
+ "memlock=-1",
32
+ "--ulimit",
33
+ "stack=67108864"
34
+ ],
35
+ // Use 'forwardPorts' to make a list of ports inside the container available locally.
36
+ "forwardPorts": [
37
+ 8888,
38
+ 6006
39
+ ],
40
+ // "workspaceMount": "source=${localWorkspaceFolder}/..,target=/workspaces/nemo2ios,type=bind,consistency=cached",
41
+ // "workspaceFolder": "/workspaces/nemo2ios",
42
+ // Use 'portsAttributes' to set default properties for specific forwarded ports. More info: https://code.visualstudio.com/docs/remote/devcontainerjson-reference.
43
+ // "portsAttributes": {
44
+ // "9000": {
45
+ // "label": "Hello Remote World",
46
+ // "onAutoForward": "notify"
47
+ // }
48
+ // },
49
+ // Use 'otherPortsAttributes' to configure any ports that aren't configured using 'portsAttributes'.
50
+ // "otherPortsAttributes": {
51
+ // "onAutoForward": "silent"
52
+ // },
53
+ // Use 'postCreateCommand' to run commands after the container is created.
54
+ "postCreateCommand": [
55
+ // "pip3 install -r dev.requirements.txt -r requirements.txt"
56
+ ]
57
+ // Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
58
+ // "remoteUser": "vscode"
59
+ }
.gitattributes CHANGED
@@ -25,3 +25,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
25
  *.zip filter=lfs diff=lfs merge=lfs -text
26
  *.zstandard filter=lfs diff=lfs merge=lfs -text
27
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
25
  *.zip filter=lfs diff=lfs merge=lfs -text
26
  *.zstandard filter=lfs diff=lfs merge=lfs -text
27
  *tfevents* filter=lfs diff=lfs merge=lfs -text
28
+ *.nemo filter=lfs diff=lfs merge=lfs -text
.vscode/settings.json ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ {
2
+ "python.formatting.provider": "black"
3
+ }
CnLgGm025_SpeUni1024_DI_EATL.nemo ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:94d7a7443c60dddb1e7ddfdcf5f2e85a2a857b2bc31bf20b4aedf8979b866183
3
+ size 566712320
app.py CHANGED
@@ -1,36 +1,22 @@
1
  import gradio as gr
2
- from gradio import mix
3
- from gradio import inputs, outputs # noqa: F401
4
- import hydra
5
- from omegaconf import DictConfig
6
 
7
- from models_evaluation.models import BaseModel
 
8
 
9
 
10
- @hydra.main(version_base=None, config_path="conf", config_name="gradio-asr.yaml")
11
- def main(cfg: DictConfig):
12
- audio_input = gr.inputs.Audio(source=cfg.gradio.source, type="file", label="Audio")
 
 
 
 
 
13
 
14
- default_kwargs = {
15
- "theme": "dark-huggingface",
16
- "allow_flagging": "manual",
17
- "title": cfg.gradio.title,
18
- }
19
 
20
- all_io = []
21
- models = []
22
- for model_cfg in cfg.models:
23
- model = hydra.utils.instantiate(model_cfg) # type: BaseModel
24
- model_cfg = model_cfg.cfg
25
- models.append(model)
26
- io = gr.Interface(
27
- model.transcribe, inputs=audio_input, outputs=gr.outputs.JSON(label=model_cfg.name)
28
- )
29
- all_io.append(io)
30
-
31
- parallel = mix.Parallel(*all_io, **default_kwargs)
32
- parallel.launch(share=True, debug=True)
33
-
34
-
35
- if __name__ == "__main__":
36
- main()
1
  import gradio as gr
2
+ import nemo.collections.asr as nemo_asr
 
 
 
3
 
4
+ model = nemo_asr.models.ASRModel.restore_from("CnLgGm025_SpeUni1024_DI_EATL.nemo")
5
+ model.eval()
6
 
7
 
8
+ def transcribe(audio_file):
9
+ # import speech_recognition as sr
10
+ # r = sr.Recognizer()
11
+ # with sr.AudioFile(audio_file) as source:
12
+ # audio = r.record(source)
13
+ # return r.recognize_google(audio)
14
+ t = model.transcribe([audio_file])
15
+ return t[0]
16
 
 
 
 
 
 
17
 
18
+ gr.Interface(
19
+ transcribe,
20
+ inputs=gr.inputs.Audio(source="microphone", type="filepath"),
21
+ outputs="text",
22
+ ).launch()