File size: 1,894 Bytes
cc25c78
 
 
 
 
8932c09
cc25c78
 
8932c09
 
cc25c78
 
8932c09
cc25c78
 
8932c09
cc25c78
8932c09
cc25c78
8932c09
cc25c78
 
 
 
 
 
 
 
 
 
 
 
 
8932c09
cc25c78
8932c09
cc25c78
 
 
 
8932c09
cc25c78
 
 
 
 
 
8932c09
 
cc25c78
 
 
 
 
 
 
 
 
8932c09
cc25c78
231e5bb
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
# import sys
# import os
# import gradio as gr

# sys.path.append(os.path.dirname(os.path.abspath(__file__)))

# from utils import ArgumentParser, LOG
# from translator import PDFTranslator, TranslationConfig


# def translation(input_file, source_language, target_language):
#     LOG.debug(f"[翻译任务]\n源文件: {input_file.name}\n源语言: {source_language}\n目标语言: {target_language}")

#     output_file_path = Translator.translate_pdf(
#         input_file.name, source_language=source_language, target_language=target_language)

#     return output_file_path

# def launch_gradio():

#     iface = gr.Interface(
#         fn=translation,
#         title="OpenAI-Translator v2.0(PDF 电子书翻译工具)",
#         inputs=[
#             gr.File(label="上传PDF文件"),
#             gr.Textbox(label="源语言(默认:英文)", placeholder="English", value="English"),
#             gr.Textbox(label="目标语言(默认:中文)", placeholder="Chinese", value="Chinese")
#         ],
#         outputs=[
#             gr.File(label="下载翻译文件")
#         ],
#         allow_flagging="never"
#     )

#     iface.launch(share=True, server_name="127.0.0.1")

# def initialize_translator():
#     # 解析命令行
#     argument_parser = ArgumentParser()
#     args = argument_parser.parse_arguments()

#     # 初始化配置单例
#     config = TranslationConfig()
#     config.initialize(args)    
#     # 实例化 PDFTranslator 类,并调用 translate_pdf() 方法
#     global Translator
#     Translator = PDFTranslator(config.model_name)


# if __name__ == "__main__":
#     # 初始化 translator
#     initialize_translator()
#     # 启动 Gradio 服务
#     launch_gradio()
import gradio as gr

def greet(name):
    return "Hello " + name + "!"

demo = gr.Interface(fn=greet, inputs="text", outputs="text")
demo.launch(share=True)