File size: 2,728 Bytes
7c264ed
 
a3dfd40
7c264ed
 
4fd1979
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
cd3d093
 
abf4233
4fd1979
 
 
 
 
 
 
 
 
 
 
 
7c264ed
4fd1979
7c264ed
abf4233
4fd1979
7c264ed
 
 
 
4fd1979
 
 
 
 
 
 
 
 
7c264ed
 
 
 
4fd1979
7c264ed
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import gradio as gr
from gradio_client import Client
import ast


def call_api(transcript):
    client = Client("http://47.103.63.15:50085/")
    prompt = """
    INSTRUCTIONS:
    Convert this Transcript into Segment Cards.

    IMPORTANT:
    - Maintain Language Consistency: Ensure that the language used in segment cards matches the transcription for clarity.
    - Verify Duration Accuracy: Double-check that the stated duration of each segment card accurately reflects the content's length.
    - Avoid Special Characters and Emojis: Refrain from using special characters or emojis in segment card descriptions for a clean and professional appearance.
    - There should be exactly the same number of segment cards as the transcript has segments
    - Match the Number of Segment Cards: Create a segment card for each segment in the transcription to align with the video content.
    - Focus Solely on Segment Cards: Output only the segment cards without any additional text or commentary.
    - Implement <card> Tags: Properly format each segment card by including <card> tags before and after the card content.
    - Precision and Completeness: Craft each segment card with precision and ensure it contains complete and relevant information.
    - Adhere to Output Format: Format your answers according to the specified Output Format.
    - Consider YouTube Short Video Rating: Evaluate the content's quality in terms of suitability for YouTube Short videos when providing a rating.
    - Make Sure the Title is no more than 50 characters
    - Make Sure the Description is no more than 100 characters
    - emphasize the importance of using the same language as the transcript in segment cards to ensure coherence and accuracy.
    - use the same language for your answer as the transcript
    - Only Output 1 Segment Card for each Segment in the Transcription

    
    CONTENT OF CARD:
    {
    Title: (max. 50 Characters)
    Description: (summary of content max. 140 Characters)
    Rating: 1-5
    Duration: [00:00.000 - 00:00.000]
    }
    TRANSCRIPT: 
    """
    transcript = str(transcript)
    result = client.predict(
        prompt + transcript,
        0.9,
        2048,
        api_name="/predict"
    )
    return result


def transcription_to_segments(transcript):
    transcript = ast.literal_eval(transcript)
    segment_cards_array = []
    for segment in transcript:
        result = call_api(segment)
        segment_cards_array.append(result)
    return segment_cards_array


# Define the Gradio interface for transcription and segmentation
interface = gr.Interface(
    fn=transcription_to_segments,
    inputs="text",
    outputs="textbox"
)

# Launch the Gradio interface
interface.launch()