seawolf2357
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
-
import os
|
2 |
import gradio as gr
|
3 |
from google.cloud import translate_v2 as translate
|
|
|
4 |
from nltk import download
|
5 |
from nltk.tokenize import word_tokenize
|
6 |
from nltk.corpus import stopwords
|
@@ -24,7 +24,9 @@ def extract_keywords(text):
|
|
24 |
|
25 |
def translate_and_extract_keywords(text, api_key):
|
26 |
# 클라이언트 설정
|
27 |
-
|
|
|
|
|
28 |
# 입력받은 한글 문장을 영어로 번역
|
29 |
result = translate_client.translate(text, target_language='en')
|
30 |
translated_text = result['translatedText']
|
|
|
|
|
1 |
import gradio as gr
|
2 |
from google.cloud import translate_v2 as translate
|
3 |
+
from google.oauth2 import service_account
|
4 |
from nltk import download
|
5 |
from nltk.tokenize import word_tokenize
|
6 |
from nltk.corpus import stopwords
|
|
|
24 |
|
25 |
def translate_and_extract_keywords(text, api_key):
|
26 |
# 클라이언트 설정
|
27 |
+
credentials_info = {'type': 'service_account', 'project_id': 'your-project-id', 'private_key_id': 'your-private-key-id', 'private_key': api_key, 'client_email': 'your-service-account-email', 'client_id': 'your-client-id', 'auth_uri': 'https://accounts.google.com/o/oauth2/auth', 'token_uri': 'https://oauth2.googleapis.com/token', 'auth_provider_x509_cert_url': 'https://www.googleapis.com/oauth2/v1/certs', 'client_x509_cert_url': 'your-cert-url'}
|
28 |
+
credentials = service_account.Credentials.from_service_account_info(credentials_info)
|
29 |
+
translate_client = translate.Client(credentials=credentials)
|
30 |
# 입력받은 한글 문장을 영어로 번역
|
31 |
result = translate_client.translate(text, target_language='en')
|
32 |
translated_text = result['translatedText']
|