Ifeanyi commited on
Commit
d7b93e5
·
verified ·
1 Parent(s): 84745c0

Upload script.py

Browse files
Files changed (1) hide show
  1. script.py +92 -0
script.py ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import assemblyai as aai
2
+ import google.generativeai as genai
3
+
4
+ def audioTranscribe(audio_file,translation):
5
+
6
+ genai.configure(api_key="AIzaSyAs726sBS7iWEO7ql2LFbvCxJ_bzbpDbiI")
7
+
8
+ model = genai.GenerativeModel("gemini-1.5-pro-002")
9
+
10
+ aai.settings.api_key = "ea464e0203e74bbb87d4cdc02c56831b"
11
+ transcriber = aai.Transcriber()
12
+ transcript = transcriber.transcribe(audio_file)
13
+
14
+ if translation == "French":
15
+
16
+ prompt = "I want you to simply translate this text into French. Do not elaborate on the text."
17
+
18
+ response = model.generate_content([transcript.text,prompt])
19
+
20
+ elif translation == "Spanish":
21
+ prompt = "I want you to simply translate this text into Spanish. Do not elaborate on the text"
22
+
23
+ response = model.generate_content([transcript.text,prompt])
24
+
25
+ elif translation == "German":
26
+ prompt = "I want you to simply translate this text into German. Do not elaborate on the text."
27
+
28
+ response = model.generate_content([transcript.text,prompt])
29
+
30
+ elif translation == "Italian":
31
+ prompt = "I want you to simply translate this text into Italian. Do not elaborate on the text."
32
+
33
+ response = model.generate_content([transcript.text,prompt])
34
+
35
+ elif translation == "Japanese":
36
+ prompt = "I want you to simply translate this text into Japanese. Do not elaborate on the text."
37
+
38
+ response = model.generate_content([transcript.text,prompt])
39
+
40
+ elif translation == "Portuguese":
41
+ prompt = "I want you to simply translate this text into Portuguese. Do not elaborate on the text."
42
+
43
+ response = model.generate_content([transcript.text,prompt])
44
+
45
+ elif translation == "Dutch":
46
+ prompt = "I want you to simply translate this text into Dutch. Do not elaborate on the text."
47
+
48
+ response = model.generate_content([transcript.text,prompt])
49
+
50
+ elif translation == "Korean":
51
+ prompt = "I want you to simply translate this text into Korean. Do not elaborate on the text."
52
+
53
+ response = model.generate_content([transcript.text,prompt])
54
+
55
+ elif translation == "Hindi":
56
+ prompt = "I want you to simply translate this text into Hindi. Do not elaborate on the text."
57
+
58
+ response = model.generate_content([transcript.text,prompt])
59
+
60
+ elif translation == "Igbo":
61
+ prompt = "I want you to simply translate this text into Igbo. Do not elaborate on the text."
62
+
63
+ response = model.generate_content([transcript.text,prompt])
64
+
65
+ elif translation == "Yoruba":
66
+ prompt = "I want you to simply translate this text into Yoruba. Do not elaborate on the text."
67
+
68
+ response = model.generate_content([transcript.text,prompt])
69
+
70
+ elif translation == "Polish":
71
+ prompt = "I want you to simply translate this text into Polish. Do not elaborate on the text."
72
+
73
+ response = model.generate_content([transcript.text,prompt])
74
+
75
+ elif translation == "Swahili":
76
+ prompt = "I want you to simply translate this text into Swahili. Do not elaborate on the text."
77
+
78
+ response = model.generate_content([transcript.text,prompt])
79
+
80
+ elif translation == "Turkish":
81
+ prompt = "I want you to simply translate this text into Turkish. Do not elaborate on the text."
82
+
83
+ response = model.generate_content([transcript.text,prompt])
84
+
85
+ elif translation == "Hausa":
86
+ prompt = "I want you to simply translate this text into Hausa. Do not elaborate on the text."
87
+
88
+ response = model.generate_content([transcript.text,prompt])
89
+
90
+
91
+ return [transcript.text, response.text]
92
+