supernovamutinda commited on
Commit
d158642
·
1 Parent(s): 69b0eb6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -79
app.py CHANGED
@@ -1,86 +1,30 @@
1
  import streamlit as st
2
- import gradio as gr
3
- import os
4
- from gradio_client import Client
5
 
 
 
6
 
7
- with st.sidebar:
8
- st.image("https://www.onepointltd.com/wp-content/uploads/2020/03/inno2.png")
9
- st.title("Campus Comrade Assistant")
10
- choice = st.radio("Navigation", ["Home/about","Meal Suggester","Accomodation available", "Assignment assist", "Events", "Transcribe, audio to Text"])
11
- st.info("This project application helps you accomplish both major and minor tasks efficiently.")
12
 
13
- if choice == "Home/about":
14
- st.title("Welcome to Campus Comrade Assitant")
15
-
16
- if choice == "Meal Suggester":
17
- st.title("Time to Eat")
18
 
19
- if choice == "Accomodation available":
20
- st.title("Ready to Move in?")
 
 
 
 
 
 
 
 
 
 
 
21
 
22
- if choice == "Assignment assist":
23
- st.title("Let's complete that assignment")
24
-
25
- if choice == "Events":
26
- st.title("Collaborate and Jazz. Events around You")
27
 
28
- if choice == "Transcribe, audio to Text":
29
- st.title("Tired of listening long audio? convert to Text")
30
-
31
- def transcribe_audio(youtube_url: str, task: str = "transcribe", return_timestamps: bool = False, api_name: str = "/predict_2") -> dict:
32
- """
33
- Transcribe audio from a given YouTube URL using a specified model.
34
- Parameters:
35
- - youtube_url (str): The YouTube URL to transcribe.
36
- - task (str, optional): The task to perform. Default is "transcribe".
37
- - return_timestamps (bool, optional): Whether to return timestamps. Default is True.
38
- - api_name (str, optional): The API endpoint to use. Default is "/predict_2".
39
- Returns:
40
- - dict: The transcription result.
41
- """
42
- client = Client("https://sanchit-gandhi-whisper-jax.hf.space/")
43
- result = client.predict(youtube_url, task, return_timestamps, fn_index=7)
44
- return result
45
-
46
-
47
-
48
- MODEL_NAME = "openai/whisper-large-v2"
49
-
50
-
51
- demo = gr.Blocks()
52
-
53
- EXAMPLES = [
54
- ["https://www.youtube.com/watch?v=H1YoNlz2LxA", "translate",False],
55
- ]
56
-
57
-
58
- yt_transcribe = gr.Interface(
59
- fn=transcribe_audio,
60
- inputs=[
61
- gr.inputs.Textbox(lines=1, placeholder="Paste the URL to a YouTube video here", label="YouTube URL"),
62
- gr.inputs.Radio(["transcribe", "translate"], label="Task", default="transcribe"),
63
- gr.inputs.Checkbox(label="Return timestamps")
64
- ],
65
- outputs=[gr.outputs.HTML(label="Video"),
66
- gr.outputs.Textbox(label="Transcription").style(show_copy_button=True)],
67
- layout="horizontal",
68
- theme=gr.themes.Base(),
69
- title="Whisper Large V2: Transcribe YouTube",
70
- description=(
71
- "Transcribe long-form YouTube videos with the click of a button! Demo uses the checkpoint"
72
- f" [{MODEL_NAME}](https://huggingface.co/{MODEL_NAME}) and 🤗 Transformers to transcribe video files of"
73
- " arbitrary length."
74
- ),
75
- allow_flagging="never",
76
- examples=EXAMPLES,
77
- cache_examples=False
78
- )
79
-
80
- with demo:
81
- gr.DuplicateButton()
82
- gr.TabbedInterface([yt_transcribe], [ "YouTube"])
83
-
84
- demo.launch(enable_queue=True)
85
-
86
-
 
1
  import streamlit as st
2
+ from transformers import pipeline
 
 
3
 
4
+ # Initialize the transcription pipeline
5
+ transcribe = pipeline(model="openai/whisper-large-v2")
6
 
7
+ # Streamlit page configuration
8
+ st.title("Transcription Service")
9
+ st.write("Upload a YouTube URL or an audio file to transcribe.")
 
 
10
 
11
+ # Input: YouTube URL or Audio File
12
+ url = st.text_input("Enter YouTube URL:")
13
+ audio_file = st.file_uploader("Or upload an audio file (mp3, wav):")
 
 
14
 
15
+ if url:
16
+ # Process the YouTube URL and extract audio for transcription
17
+ # Note: You'll need to implement the extraction of audio from YouTube URL
18
+ st.write("Transcribing from YouTube URL...")
19
+ # audio_data = extract_audio_from_url(url) # Placeholder for actual extraction function
20
+ # transcription = transcribe(audio_data)
21
+ # st.write(transcription)
22
+ st.write("YouTube URL transcription is not implemented yet.")
23
+ elif audio_file:
24
+ # Process the uploaded audio file for transcription
25
+ st.write("Transcribing from uploaded audio file...")
26
+ transcription = transcribe(audio_file.getvalue())
27
+ st.write(transcription)
28
 
29
+ st.write("Thank you for using our service!")
 
 
 
 
30