File size: 2,829 Bytes
93a8660
 
db11b12
58110bd
 
 
f3dee0b
93a8660
58110bd
 
 
 
 
 
 
 
 
 
 
 
 
f3dee0b
f20a44c
93a8660
f3dee0b
 
 
93a8660
58110bd
93a8660
 
f3dee0b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58110bd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f3dee0b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
from translate import Translate  # Import the Translate class
import gradio as gr
import os

def app(video_path, original_language, target_language):
    translator = Translate(video_path, original_language, target_language)
    translated_text_file = translator.transcribe_and_translate()

    # Save the file with the desired name, ensuring a unique name if needed
    saved_file_path = "translated_text.txt"  # Replace with your preferred filename
    if os.path.exists(saved_file_path):
        base, ext = os.path.splitext(saved_file_path)
        counter = 1
        while os.path.exists(f"{base}_{counter}{ext}"):
            counter += 1
        saved_file_path = f"{base}_{counter}{ext}"
    os.rename(translated_text_file, saved_file_path)

    return saved_file_path

# Gradio's built-in File component handles download functionality
interface_text_file = gr.Interface(
    fn=app,
    inputs=[
        gr.File(label="Upload Text File"),
        gr.Dropdown(["English", "German", "French", "Spanish"], label="Original Language"),
        gr.Dropdown(["English", "German", "French", "Spanish", "Urdu"], label="Targeted Language"),
    ],
    outputs=gr.File(label="Translated Text File"),  # Gradio provides the download link
)

interface_text_file.launch(debug=True)




































# import gradio as gr

# import os
# import moviepy.editor as mp
# import assemblyai as aai
# import requests
# import azure.cognitiveservices.speech as speechsdk
# from moviepy.editor import AudioFileClip
# from gradio_client import Client

# def app(video_path,original_language, target_language):
#     translator = Translate(video_path,original_language, target_language)
#     translated_text_file = translator.transcribe_and_translate()
#     return translated_text_file

# interface_text_file = gr.Interface(
#     fn=app,
#     inputs=[
#         gr.File(label="Upload Text File"),
#         gr.Dropdown(["English", "German", "French", "Spanish"], label="Original Language"),
#         gr.Dropdown(["English", "German", "French", "Spanish", "Urdu"], label="Targeted Language"),
#     ],
#     outputs=[gr.File(label="Translated Text File")],
# )

# interface_text_file.launch(debug=True)














# interface = gr.Interface(
#     fn=app,
#     inputs=[
#         gr.components.Video(sources="upload", label="upload video"),
#         gr.Dropdown(
#             ["English", "German", "French" ,"Spanish"], label="Original Language"
#         ),
#         gr.Dropdown(
#             ["English", "German", "French" ,"Spanish","Urdu"], label="Targeted Language"
#         )
#         # gr.components.Textbox(label="Enter Float Value")

#     ],
#     outputs=outputs=[gr.components.Textbox(label="your result")]
#     # outputs=[gr.components.File(label="Your result")]
# )

# interface.launch(debug=True)