seawolf2357 commited on
Commit
91e1c1a
โ€ข
1 Parent(s): 7e85524

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -2
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
- translate_client = translate.Client(credentials=translate.Credentials(api_key))
 
 
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']