Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -8,11 +8,24 @@ API_URL = "https://api.openai.com/v1/chat/completions"
|
|
8 |
# ๋ฒ์ญ ํ์ดํ๋ผ์ธ ์ด๊ธฐํ
|
9 |
translator = pipeline("translation", model="Helsinki-NLP/opus-mt-ko-en")
|
10 |
|
11 |
-
def
|
12 |
# ์
๋ ฅ๋ ํ
์คํธ๋ฅผ ์์ด๋ก ๋ฒ์ญ
|
13 |
translation = translator(text, max_length=512)
|
14 |
translated_text = translation[0]['translation_text']
|
15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
|
17 |
def predict(inputs, top_p, temperature, openai_api_key):
|
18 |
narration_prompt = f"์๋์ฉ ์ ๋๋ฉ์ด์
๋์์์ ์ฌ์ฉํ ์คํฌ๋ฆฝํธ๋ฅผ ์์ฑํ๋ผ. ๋ฐ๋์ ํ๊ธ๋ก ์์ฑํ ๊ฒ. ์ผ์ฒด์ ์ง๋ฌธ์ด๋ ์ง์, ๊ธฐํธ ํ์, ๋ฐฐ๊ฒฝ ์ค๋ช
๋ฑ์ ๋
ธ์ถ ํ๊ฑฐ๋ ์ถ๋ ฅํ์ง ๋ง๊ณ ๊ธฐ์น์ ๊ฒฐ์ ๊ตฌ์กฐ๋ก ๋ชจํ์ ์ด์ /์๊ธฐ/๋์ /๋ฌธ์ ํด๊ฒฐ/๊ตํ์ ํฌํจํ์ฌ ์์ํ ๋๋ ์ด์
๋ง 1์ค์ฉ ์ถ๋ ฅํ์ฌ ์ต๋ 10์ค ์ด๋ด๋ก ์ถ๋ ฅ. ์
๋ ฅ: '{inputs}'"
|
@@ -37,9 +50,9 @@ def predict(inputs, top_p, temperature, openai_api_key):
|
|
37 |
return "Error: Unable to generate response."
|
38 |
|
39 |
def generate_prompts(script):
|
40 |
-
# ์คํฌ๋ฆฝํธ์ ๊ฐ ์ค์ ์์ด๋ก
|
41 |
lines = script.split('\n')
|
42 |
-
translated_prompts = [
|
43 |
return "\n".join(translated_prompts)
|
44 |
|
45 |
with gr.Blocks() as demo:
|
|
|
8 |
# ๋ฒ์ญ ํ์ดํ๋ผ์ธ ์ด๊ธฐํ
|
9 |
translator = pipeline("translation", model="Helsinki-NLP/opus-mt-ko-en")
|
10 |
|
11 |
+
def translate_and_generate_prompts(text):
|
12 |
# ์
๋ ฅ๋ ํ
์คํธ๋ฅผ ์์ด๋ก ๋ฒ์ญ
|
13 |
translation = translator(text, max_length=512)
|
14 |
translated_text = translation[0]['translation_text']
|
15 |
+
|
16 |
+
# ๊ธฐ๋ณธ ํค์๋ ์ถ๊ฐ
|
17 |
+
prompt = "3d style, 4k"
|
18 |
+
|
19 |
+
# ์ง์ ํค์๋ ์ถ๊ฐ
|
20 |
+
if "ํ ๋ฆฌ" in text:
|
21 |
+
prompt += ", like Brad Pitt young boy"
|
22 |
+
elif "์ค๋ฆฌ" in text:
|
23 |
+
prompt += ", like Emma Watson young girl"
|
24 |
+
|
25 |
+
# ๋ฒ์ญ๋ ํ
์คํธ ์ถ๊ฐ
|
26 |
+
prompt += f", {translated_text}"
|
27 |
+
|
28 |
+
return prompt
|
29 |
|
30 |
def predict(inputs, top_p, temperature, openai_api_key):
|
31 |
narration_prompt = f"์๋์ฉ ์ ๋๋ฉ์ด์
๋์์์ ์ฌ์ฉํ ์คํฌ๋ฆฝํธ๋ฅผ ์์ฑํ๋ผ. ๋ฐ๋์ ํ๊ธ๋ก ์์ฑํ ๊ฒ. ์ผ์ฒด์ ์ง๋ฌธ์ด๋ ์ง์, ๊ธฐํธ ํ์, ๋ฐฐ๊ฒฝ ์ค๋ช
๋ฑ์ ๋
ธ์ถ ํ๊ฑฐ๋ ์ถ๋ ฅํ์ง ๋ง๊ณ ๊ธฐ์น์ ๊ฒฐ์ ๊ตฌ์กฐ๋ก ๋ชจํ์ ์ด์ /์๊ธฐ/๋์ /๋ฌธ์ ํด๊ฒฐ/๊ตํ์ ํฌํจํ์ฌ ์์ํ ๋๋ ์ด์
๋ง 1์ค์ฉ ์ถ๋ ฅํ์ฌ ์ต๋ 10์ค ์ด๋ด๋ก ์ถ๋ ฅ. ์
๋ ฅ: '{inputs}'"
|
|
|
50 |
return "Error: Unable to generate response."
|
51 |
|
52 |
def generate_prompts(script):
|
53 |
+
# ์คํฌ๋ฆฝํธ์ ๊ฐ ์ค์ ์์ด๋ก ๋ฒ์ญํ๊ณ ํ๋กฌํํธ ์์ฑ
|
54 |
lines = script.split('\n')
|
55 |
+
translated_prompts = [translate_and_generate_prompts(line) for line in lines if line.strip() != '']
|
56 |
return "\n".join(translated_prompts)
|
57 |
|
58 |
with gr.Blocks() as demo:
|