bipin
commited on
Commit
•
a1bee8a
1
Parent(s):
b69fb46
update to initial prompting for StyleVehicle
Browse files- app.py +52 -9
- video_transcriber.py +57 -0
app.py
CHANGED
@@ -80,19 +80,62 @@ if uploaded_file:
|
|
80 |
else:
|
81 |
pdf_text = ""
|
82 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
83 |
initial_prompt = f"""
|
84 |
Imagine you are a seasoned researcher specializing in the field of {research_field}.
|
85 |
-
You are presented with a research paper within your domain. Evaluate its working methodology
|
86 |
-
|
87 |
-
research
|
88 |
-
|
|
|
|
|
89 |
|
90 |
Output will be as,
|
91 |
-
|
92 |
-
Research Summary
|
93 |
-
|
94 |
-
|
95 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
96 |
|
97 |
if option=='':
|
98 |
with st.spinner("Processing..."):
|
|
|
80 |
else:
|
81 |
pdf_text = ""
|
82 |
|
83 |
+
#"""
|
84 |
+
#initial_prompt = f
|
85 |
+
#Imagine you are a seasoned researcher specializing in the field of {research_field}.
|
86 |
+
#You are presented with a research paper within your domain. Evaluate its working methodology
|
87 |
+
#and discuss its research impact through concise bullet points. Conclude by summarizing the
|
88 |
+
#research paper and propose three questions for the user based on the paper's context. Finnaly
|
89 |
+
#remeber the research paper context for the next questions.
|
90 |
+
|
91 |
+
#Output will be as,
|
92 |
+
#Research Paper Title \n
|
93 |
+
#Research Summary \n
|
94 |
+
#Methodology \n
|
95 |
+
#Research Impact \n
|
96 |
+
#Suggested Questions
|
97 |
+
|
98 |
+
#"""
|
99 |
+
|
100 |
+
|
101 |
initial_prompt = f"""
|
102 |
Imagine you are a seasoned researcher specializing in the field of {research_field}.
|
103 |
+
You are presented with a research paper within your domain. Evaluate its working methodology including model architecture
|
104 |
+
which can be Predefined, Custom Predefined, Own Model or other, explain with architecture
|
105 |
+
and discuss its research impact through concise bullet points. Research about dataset conditions and domain adaptation technqiues.
|
106 |
+
Conclude by summarizing the
|
107 |
+
research paper and propose three questions for the user based on the paper's context. Remember
|
108 |
+
the research paper context for the next questions.
|
109 |
|
110 |
Output will be as,
|
111 |
+
Title\n
|
112 |
+
Research Summary\n
|
113 |
+
Methods or Models Used
|
114 |
+
Dataset Used
|
115 |
+
- Name:
|
116 |
+
- Size:
|
117 |
+
- Number of Images:
|
118 |
+
- Resolution:
|
119 |
+
- Instances:
|
120 |
+
Dataset Condition
|
121 |
+
- Day, Night, Mix, Weather:
|
122 |
+
Domain Adaptation Technique:
|
123 |
+
- Used (or not)
|
124 |
+
- Method:
|
125 |
+
- D2N (Day to Night)
|
126 |
+
- N2D (Night to Day)
|
127 |
+
- Mix Image Generation
|
128 |
+
Output Image Resolution
|
129 |
+
- Resolution:
|
130 |
+
- Upsampling Technique Used:
|
131 |
+
Experiment Process and Objectives:
|
132 |
+
- Steps:
|
133 |
+
- Objectives:
|
134 |
+
Detection/Segmentation Models:
|
135 |
+
Performance Improvements:
|
136 |
+
- Tradeoff:
|
137 |
+
Suggested Questions:
|
138 |
+
"""
|
139 |
|
140 |
if option=='':
|
141 |
with st.spinner("Processing..."):
|
video_transcriber.py
ADDED
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import moviepy.editor as mp
|
2 |
+
import speech_recognition as sr
|
3 |
+
import os
|
4 |
+
|
5 |
+
def transcribe_audio_chunk(audio_chunk):
|
6 |
+
recognizer = sr.Recognizer()
|
7 |
+
with sr.AudioFile(audio_chunk) as source:
|
8 |
+
audio_data = recognizer.record(source)
|
9 |
+
|
10 |
+
try:
|
11 |
+
text_result = recognizer.recognize_google(audio_data, language='en-US')
|
12 |
+
return text_result
|
13 |
+
except sr.UnknownValueError:
|
14 |
+
print("Speech Recognition could not understand audio")
|
15 |
+
return ""
|
16 |
+
except sr.RequestError as e:
|
17 |
+
print(f"Could not request results from Google Speech Recognition service; {e}")
|
18 |
+
return ""
|
19 |
+
|
20 |
+
def transcribe_video(video_path):
|
21 |
+
# Step 1: Extract audio from the video
|
22 |
+
video_clip = mp.VideoFileClip(video_path)
|
23 |
+
audio_clip = video_clip.audio
|
24 |
+
audio_clip.write_audiofile("temp_audio.wav")
|
25 |
+
|
26 |
+
# Step 2: Split the audio into smaller chunks (e.g., 10 seconds each)
|
27 |
+
chunk_duration = 10 # in seconds
|
28 |
+
total_duration = audio_clip.duration
|
29 |
+
chunk_paths = []
|
30 |
+
|
31 |
+
for start_time in range(0, int(total_duration), chunk_duration):
|
32 |
+
end_time = min(start_time + chunk_duration, total_duration)
|
33 |
+
chunk_path = f"temp_audio_chunk_{start_time}_{end_time}.wav"
|
34 |
+
audio_chunk = audio_clip.subclip(start_time, end_time)
|
35 |
+
audio_chunk.write_audiofile(chunk_path)
|
36 |
+
chunk_paths.append(chunk_path)
|
37 |
+
|
38 |
+
# Step 3: Transcribe each audio chunk
|
39 |
+
transcribed_texts = []
|
40 |
+
for chunk_path in chunk_paths:
|
41 |
+
text_result = transcribe_audio_chunk(chunk_path)
|
42 |
+
transcribed_texts.append(text_result)
|
43 |
+
|
44 |
+
# Step 4: Concatenate the transcribed texts
|
45 |
+
final_transcription = " ".join(transcribed_texts)
|
46 |
+
print("Transcription:\n", final_transcription)
|
47 |
+
|
48 |
+
# Clean up temporary files
|
49 |
+
audio_clip.close()
|
50 |
+
video_clip.close()
|
51 |
+
os.remove("temp_audio.wav")
|
52 |
+
for chunk_path in chunk_paths:
|
53 |
+
os.remove(chunk_path)
|
54 |
+
|
55 |
+
# Example usage
|
56 |
+
video_path = "C:/Users/HP/Downloads/Video/1.mp4"
|
57 |
+
transcribe_video(video_path)
|