Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -4,6 +4,7 @@ import os
|
|
4 |
from io import BytesIO
|
5 |
import tempfile
|
6 |
import boto3
|
|
|
7 |
|
8 |
s3 = boto3.client(
|
9 |
's3',
|
@@ -12,6 +13,10 @@ s3 = boto3.client(
|
|
12 |
region_name='ap-northeast-1'
|
13 |
)
|
14 |
|
|
|
|
|
|
|
|
|
15 |
def create_meeting_summary(uploaded_audio):
|
16 |
openai.api_key = os.environ["OPENAI_API_KEY"]
|
17 |
transcript = openai.Audio.transcribe("whisper-1", open(uploaded_audio, "rb"), response_format="verbose_json")
|
@@ -20,10 +25,10 @@ def create_meeting_summary(uploaded_audio):
|
|
20 |
transcript_text += f"{segment['text']}\n"
|
21 |
|
22 |
bucket_name = "ling-transcribe"
|
23 |
-
file_name = f"
|
24 |
s3.put_object(Bucket=bucket_name, Key=file_name, Body=transcript_text)
|
25 |
|
26 |
-
download_url = os.environ["DOWNLOAD_URL"] +
|
27 |
|
28 |
return download_url
|
29 |
|
|
|
4 |
from io import BytesIO
|
5 |
import tempfile
|
6 |
import boto3
|
7 |
+
import random, string
|
8 |
|
9 |
s3 = boto3.client(
|
10 |
's3',
|
|
|
13 |
region_name='ap-northeast-1'
|
14 |
)
|
15 |
|
16 |
+
def randomstring(n):
|
17 |
+
randlst = [random.choice(string.ascii_letters + string.digits) for i in range(n)]
|
18 |
+
return ''.join(randlst)
|
19 |
+
|
20 |
def create_meeting_summary(uploaded_audio):
|
21 |
openai.api_key = os.environ["OPENAI_API_KEY"]
|
22 |
transcript = openai.Audio.transcribe("whisper-1", open(uploaded_audio, "rb"), response_format="verbose_json")
|
|
|
25 |
transcript_text += f"{segment['text']}\n"
|
26 |
|
27 |
bucket_name = "ling-transcribe"
|
28 |
+
file_name = f"test_{randomstring(8)}.txt"
|
29 |
s3.put_object(Bucket=bucket_name, Key=file_name, Body=transcript_text)
|
30 |
|
31 |
+
download_url = os.environ["DOWNLOAD_URL"] + file_name
|
32 |
|
33 |
return download_url
|
34 |
|