englissi commited on
Commit
8d444a7
Β·
verified Β·
1 Parent(s): ca7f474

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -13
app.py CHANGED
@@ -2,24 +2,25 @@ import gradio as gr
2
  import torch
3
  from transformers import pipeline
4
 
5
- # Use a pipeline as a high-level helper
6
- from transformers import pipeline
7
-
8
- pipe = pipeline("automatic-speech-recognition", model="infinitejoy/wav2vec2-large-xls-r-300m-bulgarian")
9
 
10
 
11
- # TTS λ³€ν™˜ ν•¨μˆ˜
12
- def tts_generate(text):
13
- audio = tts(text, return_tensors=True)
14
- return (audio['speech'].numpy(), 22050) # λ°˜ν™˜ν•  μƒ˜ν”Œλ§ 속도와 μ˜€λ””μ˜€ 데이터
15
 
16
  # Gradio μΈν„°νŽ˜μ΄μŠ€ 생성
17
- iface = gr.Interface(fn=tts_generate,
18
- inputs="text",
19
- outputs="audio",
20
- title="Bulgarian TTS Generator",
21
- description="Enter text to generate speech in Bulgarian.")
 
 
22
 
23
  # μΈν„°νŽ˜μ΄μŠ€ μ‹€ν–‰
24
  if __name__ == "__main__":
25
  iface.launch()
 
 
2
  import torch
3
  from transformers import pipeline
4
 
5
+ # Initialize the ASR pipeline for Bulgarian
6
+ asr_pipeline = pipeline("automatic-speech-recognition", model="infinitejoy/wav2vec2-large-xls-r-300m-bulgarian")
 
 
7
 
8
 
9
+ # ASR λ³€ν™˜ ν•¨μˆ˜ (speech-to-text conversion)
10
+ def asr_generate(audio):
11
+ transcription = asr_pipeline(audio)["text"]
12
+ return transcription
13
 
14
  # Gradio μΈν„°νŽ˜μ΄μŠ€ 생성
15
+ iface = gr.Interface(
16
+ fn=asr_generate,
17
+ inputs=gr.Audio(source="microphone", type="filepath"),
18
+ outputs="text",
19
+ title="Bulgarian Speech Recognition",
20
+ description="Upload or record audio in Bulgarian to get the transcription."
21
+ )
22
 
23
  # μΈν„°νŽ˜μ΄μŠ€ μ‹€ν–‰
24
  if __name__ == "__main__":
25
  iface.launch()
26
+