Spaces:
Build error
Build error
seiching
commited on
Commit
·
4082345
1
Parent(s):
def0108
增加使用者可以自己的prompt
Browse files
app.py
CHANGED
|
@@ -9,6 +9,7 @@ genaikey=os.environ['genaikey']
|
|
| 9 |
#MODEL_NAME = "seiching/whisper-small-seiching"
|
| 10 |
MODEL_NAME = "openai/whisper-tiny"
|
| 11 |
BATCH_SIZE = 8
|
|
|
|
| 12 |
#
|
| 13 |
device = 0 if torch.cuda.is_available() else "cpu"
|
| 14 |
|
|
@@ -261,15 +262,15 @@ def gpt4write(openaikeystr,transcribe_text,LLMmodel):
|
|
| 261 |
return finalresponse
|
| 262 |
|
| 263 |
return 'ok'
|
| 264 |
-
def gewritenote(inputscript):
|
| 265 |
api_key = genaikey
|
| 266 |
genai.configure(api_key = api_key)
|
| 267 |
model = genai.GenerativeModel('gemini-pro')
|
| 268 |
-
genprompt='你是專業的會議紀錄製作員,請根據由語音辨識軟體將會議錄音所轉錄的逐字稿,也請注意逐字稿可能有錯,請先做校正,討論內容細節請略過,請根據校正過的逐字稿撰寫會議紀錄,並要用比較正式及容易閱讀的寫法,避免口語化'
|
| 269 |
-
genprompt=
|
| 270 |
response = model.generate_content( genprompt)
|
| 271 |
return response.text
|
| 272 |
-
def writenotes( LLMmodel,apikeystr,inputscript):
|
| 273 |
#text=transcribe_text
|
| 274 |
#openaikey.set_key(inputkey)
|
| 275 |
#openaikey = OpenAIKeyClass(inputkey)
|
|
@@ -282,7 +283,7 @@ def writenotes( LLMmodel,apikeystr,inputscript):
|
|
| 282 |
elif LLMmodel=="gpt-4-0125-preview":
|
| 283 |
ainotestext=gpt4write(apikeystr,transcribe_text,LLMmodel)
|
| 284 |
elif LLMmodel=='gemini':
|
| 285 |
-
ainotestext=gewritenote(transcribe_text)
|
| 286 |
|
| 287 |
|
| 288 |
|
|
@@ -298,7 +299,7 @@ def writenotes( LLMmodel,apikeystr,inputscript):
|
|
| 298 |
return ainotestext
|
| 299 |
ainotes = gr.Interface(
|
| 300 |
fn=writenotes,
|
| 301 |
-
inputs=[ gr.inputs.Radio(["gemini","gpt-3.5-turbo", "gpt-4-0125-preview"], label="LLMmodel", default="gemini"),gr.Textbox(label="使用GPT請輸入OPEN AI API KEY",placeholder="請輸入sk..."),gr.Textbox(label="逐字稿",placeholder="若沒有做語音辨識,請輸入逐字稿")],
|
| 302 |
outputs="text",
|
| 303 |
layout="horizontal",
|
| 304 |
theme="huggingface",
|
|
|
|
| 9 |
#MODEL_NAME = "seiching/whisper-small-seiching"
|
| 10 |
MODEL_NAME = "openai/whisper-tiny"
|
| 11 |
BATCH_SIZE = 8
|
| 12 |
+
DEFAULTPROMPT='你是專業的會議紀錄製作員,請根據由語音辨識軟體將會議錄音所轉錄的逐字稿,也請注意逐字稿可能有錯,請先做校正,討論內容細節請略過,請根據校正過的逐字稿撰寫會議紀錄,並要用比較正式及容易閱讀的寫法,避免口語化'
|
| 13 |
#
|
| 14 |
device = 0 if torch.cuda.is_available() else "cpu"
|
| 15 |
|
|
|
|
| 262 |
return finalresponse
|
| 263 |
|
| 264 |
return 'ok'
|
| 265 |
+
def gewritenote(prompt,inputscript):
|
| 266 |
api_key = genaikey
|
| 267 |
genai.configure(api_key = api_key)
|
| 268 |
model = genai.GenerativeModel('gemini-pro')
|
| 269 |
+
#genprompt='你是專業的會議紀錄製作員,請根據由語音辨識軟體將會議錄音所轉錄的逐字稿,也請注意逐字稿可能有錯,請先做校正,討論內容細節請略過,請根據校正過的逐字稿撰寫會議紀錄,並要用比較正式及容易閱讀的寫法,避免口語化'
|
| 270 |
+
genprompt=prompt+'#'+inputscript+'#'
|
| 271 |
response = model.generate_content( genprompt)
|
| 272 |
return response.text
|
| 273 |
+
def writenotes( LLMmodel,apikeystr,prompt,inputscript):
|
| 274 |
#text=transcribe_text
|
| 275 |
#openaikey.set_key(inputkey)
|
| 276 |
#openaikey = OpenAIKeyClass(inputkey)
|
|
|
|
| 283 |
elif LLMmodel=="gpt-4-0125-preview":
|
| 284 |
ainotestext=gpt4write(apikeystr,transcribe_text,LLMmodel)
|
| 285 |
elif LLMmodel=='gemini':
|
| 286 |
+
ainotestext=gewritenote(prompt,transcribe_text)
|
| 287 |
|
| 288 |
|
| 289 |
|
|
|
|
| 299 |
return ainotestext
|
| 300 |
ainotes = gr.Interface(
|
| 301 |
fn=writenotes,
|
| 302 |
+
inputs=[ gr.inputs.Radio(["gemini","gpt-3.5-turbo", "gpt-4-0125-preview"], label="LLMmodel", default="gemini"),gr.Textbox(label="使用GPT請輸入OPEN AI API KEY",placeholder="請輸入sk..."),gr.Textbox(label="提示詞(prompt)",placeholder=DEFAULTPROMPT),gr.Textbox(label="逐字稿",placeholder="若沒有做語音辨識,請輸入逐字稿")],
|
| 303 |
outputs="text",
|
| 304 |
layout="horizontal",
|
| 305 |
theme="huggingface",
|