hadxu commited on
Commit
65c9185
1 Parent(s): b8c098b

add whisper

Browse files
Files changed (2) hide show
  1. app.py +1 -1
  2. utils.py +43 -0
app.py CHANGED
@@ -4,7 +4,7 @@ import os
4
 
5
  from faster_whisper import WhisperModel
6
  # tiny, tiny.en, base, base.en, small, small.en, medium, medium.en, large-v1, large-v2, large-v3, or large
7
- model_name = 'tiny.en'
8
  model = WhisperModel(model_name, device="cpu", download_root="./models")
9
 
10
  ydl_opts = {
 
4
 
5
  from faster_whisper import WhisperModel
6
  # tiny, tiny.en, base, base.en, small, small.en, medium, medium.en, large-v1, large-v2, large-v3, or large
7
+ model_name = 'base'
8
  model = WhisperModel(model_name, device="cpu", download_root="./models")
9
 
10
  ydl_opts = {
utils.py ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import google.generativeai as genai
2
+
3
+ API_KEY = "AIzaSyCkqv9dWrlbRjv9fHO_O8jBORGfYVPJTnY"
4
+
5
+ def call_gemini(prompt="", given_text=None, given_image=None, generation_config=None, safety_settings=None):
6
+ genai.configure(api_key=API_KEY)
7
+ generation_config = {
8
+ "temperature": 0.8,
9
+ "top_p": 1,
10
+ "top_k": 32,
11
+ "max_output_tokens": 8192,
12
+ }
13
+
14
+ safety_settings = [
15
+ {
16
+ "category": "HARM_CATEGORY_HARASSMENT",
17
+ "threshold": "BLOCK_ONLY_HIGH"
18
+ },
19
+ {
20
+ "category": "HARM_CATEGORY_HATE_SPEECH",
21
+ "threshold": "BLOCK_ONLY_HIGH"
22
+ },
23
+ {
24
+ "category": "HARM_CATEGORY_SEXUALLY_EXPLICIT",
25
+ "threshold": "BLOCK_ONLY_HIGH"
26
+ },
27
+ {
28
+ "category": "HARM_CATEGORY_DANGEROUS_CONTENT",
29
+ "threshold": "BLOCK_ONLY_HIGH"
30
+ },
31
+ ]
32
+
33
+ model = genai.GenerativeModel(model_name='gemini-pro',
34
+ generation_config=generation_config,
35
+ safety_settings=safety_settings)
36
+
37
+ prompt_parts = "如何学习rust语言?"
38
+
39
+ response = model.generate_content(prompt_parts)
40
+ print(response.text)
41
+
42
+ if __name__ == "__main__":
43
+ call_gemini()