Spaces:
Running
Running
jtlonsako
commited on
Commit
β’
17e5c93
1
Parent(s):
d29d0d4
Test 3
Browse files
app.py
CHANGED
@@ -22,38 +22,6 @@ def format_time(seconds):
|
|
22 |
# Convert seconds to hh:mm:ss,ms format
|
23 |
return str(datetime.timedelta(seconds=seconds)).replace('.', ',')
|
24 |
|
25 |
-
#function to send text strings to be translated into english
|
26 |
-
def translate_text(
|
27 |
-
text: str = "αααα« α αα α΅αα
α¨ααα£α α₯α© α₯ααα₯ααα α₯αα΄α΅",
|
28 |
-
project_id: str = "noble-feat-390914"
|
29 |
-
) -> translate.TranslationServiceClient:
|
30 |
-
"""Translating Text."""
|
31 |
-
|
32 |
-
client = translate.TranslationServiceClient()
|
33 |
-
|
34 |
-
location = "global"
|
35 |
-
|
36 |
-
parent = f"projects/{project_id}/locations/{location}"
|
37 |
-
|
38 |
-
# Translate text from English to Amharic
|
39 |
-
# Detail on supported types can be found here:
|
40 |
-
# https://cloud.google.com/translate/docs/supported-formats
|
41 |
-
response = client.translate_text(
|
42 |
-
request={
|
43 |
-
"parent": parent,
|
44 |
-
"contents": [text],
|
45 |
-
"mime_type": "text/plain", # mime types: text/plain, text/html
|
46 |
-
"source_language_code": "am",
|
47 |
-
"target_language_code": "en-US",
|
48 |
-
}
|
49 |
-
)
|
50 |
-
|
51 |
-
# Display the translation for each input text provided
|
52 |
-
#for translation in response.translations:
|
53 |
-
#print(f"Translated text: {translation.translated_text}")
|
54 |
-
|
55 |
-
return response
|
56 |
-
|
57 |
#Convert Video/Audio into 16K wav file
|
58 |
def preprocessAudio(audioFile):
|
59 |
os.system(f"ffmpeg -y -i {audioFile.name} -ar 16000 ./audio.wav")
|
|
|
22 |
# Convert seconds to hh:mm:ss,ms format
|
23 |
return str(datetime.timedelta(seconds=seconds)).replace('.', ',')
|
24 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
#Convert Video/Audio into 16K wav file
|
26 |
def preprocessAudio(audioFile):
|
27 |
os.system(f"ffmpeg -y -i {audioFile.name} -ar 16000 ./audio.wav")
|