phuntshowangdi commited on
Commit
c8fa921
1 Parent(s): 4bee3e3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -48
app.py CHANGED
@@ -1,51 +1,15 @@
1
- import streamlit as st
2
- import logging
3
- from transformers import pipeline
4
-
5
- # Setup logging
6
- logging.basicConfig(level=logging.INFO)
7
-
8
- # Load speech recognition pipeline
9
- asr = pipeline(task="automatic-speech-recognition",
10
- model="facebook/wav2vec2-base-960h")
11
-
12
- # Function for transcribing speech
13
- def transcribe_speech(audio_file):
14
- if not audio_file:
15
- logging.error("No audio file provided.")
16
- return "No audio found, please retry."
17
- try:
18
- logging.info(f"Processing file: {audio_file.name}")
19
- audio_input = audio_file.read()
20
- output = asr(audio_input)
21
- return output[0]['transcription']
22
- except Exception as e:
23
- logging.error(f"Error during transcription: {str(e)}")
24
- return f"Error processing the audio file: {str(e)}"
25
-
26
- # Streamlit app UI
27
- def main():
28
- st.title("Simple Speech Recognition App")
29
- st.write("### This app allows you to upload audio and see its transcription.")
30
-
31
- # Upload audio file
32
- audio_file = st.file_uploader("Upload Audio File", type=["wav", "mp3"])
33
- if audio_file:
34
- st.audio(audio_file, format='audio/wav')
35
-
36
- # Button to transcribe audio
37
- if st.button("Transcribe Audio"):
38
- if audio_file:
39
- transcription = transcribe_speech(audio_file)
40
- st.write("### Transcription:")
41
- st.write(transcription)
42
- else:
43
- st.warning("Please upload an audio file first.")
44
-
45
- if __name__ == "__main__":
46
- main()
47
-
48
-
49
 
50
 
51
 
 
1
+ import numpy as np
2
+
3
+ def image_classifier(inp):
4
+ confidence_scores = np.random.rand(3)
5
+ confidence_scores/= np.sum(confidence_scores)
6
+ classes= ['cable','case', 'cpu']
7
+ result= {classes[i]: confidence_scores[i] for i in range(3)}
8
+ return result
9
+
10
+ import gradio as gr
11
+ demo = gr.Interface(fn=image_classifier, inputs = "image", outputs = "label")
12
+ demo.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
 
14
 
15