File size: 4,899 Bytes
71c6a0b
 
 
0f99ede
71c6a0b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6549e58
71c6a0b
6549e58
71c6a0b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6549e58
71c6a0b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6549e58
71c6a0b
 
 
9fd5767
71c6a0b
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
import os
# Set up OpenAI API credentials
import openai
openai.api_key = os.getenv('api_token')
import gradio as gr

def get_completion(prompt, model="gpt-3.5-turbo"):
    messages = [{"role": "user", "content": prompt}]
    response = openai.ChatCompletion.create(
        model=model,
        messages=messages,
        temperature=0, # this is the degree of randomness of the model's output
    )
    return response.choices[0].message["content"]

def choose_topic(prompt, model="gpt-3.5-turbo"):
    messages = [{"role": "user", "content": prompt}]
    response = openai.ChatCompletion.create(
        model=model,
        messages=messages,
        temperature=0.9, # this is the degree of randomness of the model's output
    )
    return response.choices[0].message["content"]

def generate_topic():
  prompt_sum = f"""
  Generate a table topic that tests the impromptu speaking skills of a person. Limit it to at the max 7 words. Here are some examples:

  Life As an Object
  Walking Dictionary
  Color your world
  A second chance
  The day I met Elvis
  Did you know that I once...?
  Home is where the heart is
  What doesn't kill you makes you ......
  Keep your friends close. And your enemies closer.
"""

  response_sum = choose_topic(prompt_sum)
  return response_sum

def audio_summary(transcript):
  prompt_sum = f"""
 As Cicero, the master orator, you are tasked with evaluating the effectiveness of a persuasive speech based on his renowned "five canons of rhetoric." These canons serve as a framework for analyzing and crafting persuasive speeches and arguments. Your evaluation will focus on the following aspects:

1. Invention (Quality of Arguments and Evidence):

Assess the logical and compelling nature of the arguments presented by the speaker.
Examine the evidence provided to support the speaker's points and evaluate its credibility.
2. Arrangement (Organization and Structure):

Analyze the logical flow of the speaker's ideas and the overall structure of the argument.
Evaluate whether the arrangement of points enhances the coherence and clarity of the speech.
3. Style (Word Choice, Sentence Structure, Rhetorical Devices):

Assess the appropriateness and effectiveness of the speaker's word choice and sentence structure.
Evaluate the use of rhetorical devices to enhance the persuasiveness of the speech.
4. Memory (Use of Examples, Comparisons, Narratives):

Examine the speaker's use of examples, comparisons, and narratives to illustrate their points.
Evaluate how effectively the speaker makes their arguments memorable through storytelling.
5. Delivery (Voice, Presentation):

Assess the speaker's delivery style, including voice modulation.
Evaluate how well the delivery complements and enhances the content of the argument.
Prompt:
Imagine you are Cicero, the master orator. Your task is to evaluate the persuasive speech presented below based on your renowned "five canons of rhetoric." Provide a comprehensive evaluation report for the speaker, considering each canon's key attributes.

Speech Transcript:
{transcript}

Evaluation Report Format:

Invention:

Evaluate the quality of arguments and evidence.
Provide feedback on the logical strength of the points presented.

Arrangement:

Analyze the organization and structure of the speech.
Assess how well the logical flow enhances the speech's coherence.

Style:

Evaluate the word choice, sentence structure, and use of rhetorical devices.
Comment on the effectiveness of the speaker's stylistic choices.

Memory:

Examine the use of examples, comparisons, and narratives in the speech.
Assess how memorable the speaker's arguments are due to storytelling.

Delivery:

Evaluate the speaker's voice.
Comment on how well the delivery complements and enhances the argument.

Overall Summary of Evaluation:

Provide a concise overview of the speech's strengths and areas for improvement.

Score on a Scale of 1-10:

Assign a rating to the speech's persuasiveness, considering all five canons consistently.
Use Cicero's comprehensive framework to deliver a thoughtful evaluation that highlights the speaker's strengths while providing constructive feedback for improvement.

"""

  response_sum = get_completion(prompt_sum)
  return response_sum

def transcribe(audio):
    print(audio)

#   Whisper API

    audio_file = open(audio, "rb")
    transcript = openai.Audio.transcribe("whisper-1", audio_file)


    print(transcript)
    eval = audio_summary(transcript)

    return eval

table_topic = generate_topic()
print (table_topic)
description = "Here is your topic: " + table_topic
bot = gr.Interface(fn=transcribe, inputs=gr.Audio(source="microphone", type="filepath",label="Start speaking"), outputs="text", title="Ask Cicero: Improve your Impromptu speaking",
    description=description,
    article="Tip: Improve your impromptu speaking skills by joining a Toastmasters club")

bot.launch()