Spaces:
Runtime error
Runtime error
osanseviero
commited on
Commit
•
32f98c6
1
Parent(s):
1166b5c
Update app.py
Browse files
app.py
CHANGED
@@ -28,6 +28,9 @@ prompt = None
|
|
28 |
chain = None
|
29 |
|
30 |
|
|
|
|
|
|
|
31 |
def audio_tag(
|
32 |
audio_path,
|
33 |
sample_rate=32000,
|
@@ -56,19 +59,29 @@ def audio_tag(
|
|
56 |
# Print audio tagging top probabilities
|
57 |
|
58 |
label = labels[sorted_indexes[0]]
|
59 |
-
return formatted_message(label)
|
|
|
|
|
60 |
|
61 |
def formatted_message(audio_class):
|
62 |
if cached_audio_class != audio_class:
|
63 |
cached_audio_class = audio_class
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
72 |
suffix = f'''Source: {audio_class}
|
73 |
Length of Audio in Seconds: {audio_length}
|
74 |
Human Input: {userText}
|
@@ -84,7 +97,7 @@ def formatted_message(audio_class):
|
|
84 |
llm=OpenAI(temperature=.5, openai_api_key=session_token),
|
85 |
prompt=prompt,
|
86 |
verbose=True,
|
87 |
-
memory=ConversationalBufferWindowMemory(k=2),
|
88 |
)
|
89 |
|
90 |
output = chatgpt_chain.predict(human_input=message)
|
|
|
28 |
chain = None
|
29 |
|
30 |
|
31 |
+
def format_classname(classname):
|
32 |
+
return classname.capitalize()
|
33 |
+
|
34 |
def audio_tag(
|
35 |
audio_path,
|
36 |
sample_rate=32000,
|
|
|
59 |
# Print audio tagging top probabilities
|
60 |
|
61 |
label = labels[sorted_indexes[0]]
|
62 |
+
return formatted_message(format_classname(label))
|
63 |
+
|
64 |
+
|
65 |
|
66 |
def formatted_message(audio_class):
|
67 |
if cached_audio_class != audio_class:
|
68 |
cached_audio_class = audio_class
|
69 |
+
prefix = f"""You are going to act as a magical tool that allows for humans to communicate with non-human entities like
|
70 |
+
rocks, crackling fire, trees, animals, and the wind. In order to do this, we're going to provide you the human's text input for the conversation.
|
71 |
+
The goal is for you to embody that non-human entity and converse with the human.
|
72 |
+
|
73 |
+
Examples:
|
74 |
+
|
75 |
+
Non-human Entity: Tree
|
76 |
+
Human Input: Hello tree
|
77 |
+
Tree: Hello human, I am a tree
|
78 |
+
|
79 |
+
Let's begin:
|
80 |
+
Non-human Entity: {formatted_classname}"""
|
81 |
+
suffix = f'''{{history}}
|
82 |
+
Human Input: {{human_input}}
|
83 |
+
{formatted_classname}:'''
|
84 |
+
|
85 |
suffix = f'''Source: {audio_class}
|
86 |
Length of Audio in Seconds: {audio_length}
|
87 |
Human Input: {userText}
|
|
|
97 |
llm=OpenAI(temperature=.5, openai_api_key=session_token),
|
98 |
prompt=prompt,
|
99 |
verbose=True,
|
100 |
+
memory=ConversationalBufferWindowMemory(k=2, ai=audio_class),
|
101 |
)
|
102 |
|
103 |
output = chatgpt_chain.predict(human_input=message)
|