Skjafir commited on
Commit
dca1777
·
verified ·
1 Parent(s): 1d9d6e7

touch translation.py

Browse files
Files changed (1) hide show
  1. touch translation.py +23 -0
touch translation.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ touch translation.py
2
+ # Simple AI translation app
3
+
4
+ import sieve
5
+
6
+ # Either a local file or public URL
7
+ # sample = sieve.File(path="./sample.mp4")
8
+
9
+ sample = sieve.File(url="https://storage.googleapis.com/sieve-public-data/rogan.mp4")
10
+
11
+ print("Running transcription")
12
+ transcriber = sieve.function.get("sieve/speech_transcriber")
13
+ transcript = transcriber.run(sample)
14
+
15
+ print("Running translation")
16
+ result = []
17
+ translater = sieve.function.get("sieve/seamless_text2text")
18
+ for segment in transcript:
19
+ result.append(
20
+ translater.run(segment["text"], "eng", "spa")
21
+ )
22
+
23
+ print("Translated:", " ".join(result))