Spaces:
Sleeping
Sleeping
Commit
•
4fd1979
1
Parent(s):
1961a52
Update app.py
Browse files
app.py
CHANGED
@@ -1,32 +1,62 @@
|
|
1 |
import gradio as gr
|
2 |
from gradio_client import Client
|
3 |
-
import ast
|
4 |
-
import re
|
5 |
|
6 |
|
7 |
-
def
|
8 |
-
client = Client(
|
9 |
-
|
10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
result = client.predict(
|
12 |
-
|
13 |
-
prompt,
|
14 |
-
1024,
|
15 |
-
0.6,
|
16 |
0.9,
|
17 |
-
|
18 |
-
|
19 |
-
api_name="/chat"
|
20 |
)
|
21 |
-
print(result)
|
22 |
return result
|
23 |
|
24 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
# Define the Gradio interface for transcription and segmentation
|
26 |
interface = gr.Interface(
|
27 |
fn=transcription_to_segments,
|
28 |
inputs="text",
|
29 |
-
outputs="
|
30 |
)
|
31 |
|
32 |
# Launch the Gradio interface
|
|
|
1 |
import gradio as gr
|
2 |
from gradio_client import Client
|
|
|
|
|
3 |
|
4 |
|
5 |
+
def call_api(transcript):
|
6 |
+
client = Client("http://47.103.63.15:50085/")
|
7 |
+
prompt = """
|
8 |
+
INSTRUCTIONS:
|
9 |
+
Convert this Transcript into Segment Cards.
|
10 |
+
|
11 |
+
IMPORTANT:
|
12 |
+
- Maintain Language Consistency: Ensure that the language used in segment cards matches the transcription for clarity.
|
13 |
+
- Verify Duration Accuracy: Double-check that the stated duration of each segment card accurately reflects the content's length.
|
14 |
+
- Avoid Special Characters and Emojis: Refrain from using special characters or emojis in segment card descriptions for a clean and professional appearance.
|
15 |
+
- There should be exactly the same number of segment cards as the transcript has segments
|
16 |
+
- Match the Number of Segment Cards: Create a segment card for each segment in the transcription to align with the video content.
|
17 |
+
- Focus Solely on Segment Cards: Output only the segment cards without any additional text or commentary.
|
18 |
+
- Implement <card> Tags: Properly format each segment card by including <card> tags before and after the card content.
|
19 |
+
- Precision and Completeness: Craft each segment card with precision and ensure it contains complete and relevant information.
|
20 |
+
- Adhere to Output Format: Format your answers according to the specified Output Format.
|
21 |
+
- Consider YouTube Short Video Rating: Evaluate the content's quality in terms of suitability for YouTube Short videos when providing a rating.
|
22 |
+
- Make Sure the Title is no more than 50 characters
|
23 |
+
- Make Sure the Description is no more than 100 characters
|
24 |
+
- It is absolutly important to use the same language as the transript.
|
25 |
+
|
26 |
+
|
27 |
+
CONTENT OF CARD:
|
28 |
+
{
|
29 |
+
Title: (max. 50 Characters)
|
30 |
+
Description: (summary of content max. 140 Characters)
|
31 |
+
Rating: 1-5
|
32 |
+
Duration: [00:00.000 - 00:00.000]
|
33 |
+
}
|
34 |
+
TRANSCRIPT:
|
35 |
+
"""
|
36 |
+
transcript = str(transcript)
|
37 |
result = client.predict(
|
38 |
+
prompt + transcript,
|
|
|
|
|
|
|
39 |
0.9,
|
40 |
+
1024,
|
41 |
+
api_name="/predict"
|
|
|
42 |
)
|
|
|
43 |
return result
|
44 |
|
45 |
|
46 |
+
def transcription_to_segments(transcript):
|
47 |
+
transcript = ast.literal_eval(transcript)
|
48 |
+
segment_cards_array = []
|
49 |
+
for segment in transcript:
|
50 |
+
result = call_api(segment)
|
51 |
+
segment_cards_array.append(result)
|
52 |
+
return segment_cards_array
|
53 |
+
|
54 |
+
|
55 |
# Define the Gradio interface for transcription and segmentation
|
56 |
interface = gr.Interface(
|
57 |
fn=transcription_to_segments,
|
58 |
inputs="text",
|
59 |
+
outputs="textbox"
|
60 |
)
|
61 |
|
62 |
# Launch the Gradio interface
|