Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Update app.py
Browse files
app.py
CHANGED
@@ -1614,7 +1614,7 @@ def save_imageold(image_input, filename_txt):
|
|
1614 |
return image_input.name
|
1615 |
|
1616 |
|
1617 |
-
def process_audio(audio_input):
|
1618 |
if audio_input:
|
1619 |
transcription = client.audio.transcriptions.create(
|
1620 |
model="whisper-1",
|
@@ -1623,7 +1623,7 @@ def process_audio(audio_input):
|
|
1623 |
response = client.chat.completions.create(
|
1624 |
model=MODEL,
|
1625 |
messages=[
|
1626 |
-
{"role": "system", "content":
|
1627 |
{"role": "user", "content": [{"type": "text", "text": f"The audio transcription is: {transcription.text}"}],}
|
1628 |
],
|
1629 |
temperature=0,
|
@@ -1736,8 +1736,13 @@ def main():
|
|
1736 |
|
1737 |
|
1738 |
elif option == "Audio":
|
|
|
|
|
|
|
|
|
1739 |
audio_input = st.file_uploader("Upload an audio file", type=["mp3", "wav"])
|
1740 |
-
process_audio(audio_input)
|
|
|
1741 |
elif option == "Video":
|
1742 |
video_input = st.file_uploader("Upload a video file", type=["mp4"])
|
1743 |
process_audio_and_video(video_input)
|
|
|
1614 |
return image_input.name
|
1615 |
|
1616 |
|
1617 |
+
def process_audio(audio_input, text_input):
|
1618 |
if audio_input:
|
1619 |
transcription = client.audio.transcriptions.create(
|
1620 |
model="whisper-1",
|
|
|
1623 |
response = client.chat.completions.create(
|
1624 |
model=MODEL,
|
1625 |
messages=[
|
1626 |
+
{"role": "system", "content":{text_input}},
|
1627 |
{"role": "user", "content": [{"type": "text", "text": f"The audio transcription is: {transcription.text}"}],}
|
1628 |
],
|
1629 |
temperature=0,
|
|
|
1736 |
|
1737 |
|
1738 |
elif option == "Audio":
|
1739 |
+
text = "Transcribe and answer questions as a helpful audio music and speech assistant. "
|
1740 |
+
#text = "You are generating a transcript summary. Create a summary of the provided transcription. Respond in Markdown."
|
1741 |
+
text_input = st.text_input(label="Enter text prompt to use with Audio context.", value=text)
|
1742 |
+
|
1743 |
audio_input = st.file_uploader("Upload an audio file", type=["mp3", "wav"])
|
1744 |
+
audio_response = process_audio(audio_input, text_input)
|
1745 |
+
|
1746 |
elif option == "Video":
|
1747 |
video_input = st.file_uploader("Upload a video file", type=["mp4"])
|
1748 |
process_audio_and_video(video_input)
|