phuntshowangdi commited on
Commit
5ca36ec
1 Parent(s): eb91cf4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +35 -28
app.py CHANGED
@@ -1,30 +1,37 @@
1
  import streamlit as st
2
- import pandas as pd
3
-
4
- # Load data
5
- data = pd.read_csv("computer_parts_data.csv")
6
-
7
- # Streamlit app UI
8
- def main():
9
- st.title("Computer Parts Identifier")
10
-
11
- # Sidebar for user input
12
- st.sidebar.header("Filter Options")
13
- brand = st.sidebar.text_input("Brand")
14
- price_range = st.sidebar.slider("Price Range", min_value=0, max_value=2000, value=(0, 2000))
15
- # Add more filter options as needed
16
-
17
- # Filter data based on user input
18
- filtered_data = data[(data['Brand'].str.contains(brand, na=False)) &
19
- (data['Price'] >= price_range[0]) &
20
- (data['Price'] <= price_range[1])]
21
- # Add more filtering conditions as needed
22
-
23
- # Display filtered results
24
- st.subheader("Matching Computer Parts")
25
- st.write(filtered_data)
26
-
27
- if __name__ == "__main__":
28
- main()
29
-
 
 
 
 
 
 
 
30
 
 
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 automatic speech recognition (ASR) pipeline
9
+ asr = pipeline(task="automatic-speech-recognition",
10
+ model="distil-whisper/distil-small.en")
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
+ output = asr(audio_file.name) # Assuming `asr` directly takes a file path
20
+ return output[0]["transcription"]
21
+ except Exception as e:
22
+ logging.error(f"Error during transcription: {str(e)}")
23
+ return f"Error processing the audio file: {str(e)}"
24
+
25
+ # Streamlit UI
26
+ st.title("Speech Recognition")
27
+
28
+ uploaded_file = st.file_uploader("Upload audio file", type=["wav", "mp3"])
29
+
30
+ if uploaded_file:
31
+ st.audio(uploaded_file, format='audio/wav')
32
+
33
+ if st.button("Transcribe Audio"):
34
+ transcription = transcribe_speech(uploaded_file)
35
+ st.write("Transcription:")
36
+ st.write(transcription)
37