Spaces:
Runtime error
Runtime error
Commit
·
7519d09
1
Parent(s):
bed83d4
Update baidu_translate/module.py
Browse files
baidu_translate/module.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
import argparse
|
| 2 |
-
import random
|
| 3 |
from hashlib import md5
|
| 4 |
from typing import Optional
|
| 5 |
|
|
@@ -28,13 +28,15 @@ class BaiduTranslate:
|
|
| 28 |
:param appid: appid for requesting Baidu translation service.
|
| 29 |
:param appkey: appkey for requesting Baidu translation service.
|
| 30 |
"""
|
|
|
|
|
|
|
| 31 |
# Set your own appid/appkey.
|
| 32 |
-
if appid
|
| 33 |
-
self.appid = '
|
| 34 |
else:
|
| 35 |
self.appid = appid
|
| 36 |
if appkey is None:
|
| 37 |
-
self.appkey = '
|
| 38 |
else:
|
| 39 |
self.appkey = appkey
|
| 40 |
self.url = 'http://api.fanyi.baidu.com/api/trans/vip/translate'
|
|
|
|
| 1 |
import argparse
|
| 2 |
+
import random, os
|
| 3 |
from hashlib import md5
|
| 4 |
from typing import Optional
|
| 5 |
|
|
|
|
| 28 |
:param appid: appid for requesting Baidu translation service.
|
| 29 |
:param appkey: appkey for requesting Baidu translation service.
|
| 30 |
"""
|
| 31 |
+
appid = os.environ.get('baidu_translate_appid')
|
| 32 |
+
appkey = os.environ.get('baidu_translate_appkey')
|
| 33 |
# Set your own appid/appkey.
|
| 34 |
+
if appid is None:
|
| 35 |
+
self.appid = ''
|
| 36 |
else:
|
| 37 |
self.appid = appid
|
| 38 |
if appkey is None:
|
| 39 |
+
self.appkey = ''
|
| 40 |
else:
|
| 41 |
self.appkey = appkey
|
| 42 |
self.url = 'http://api.fanyi.baidu.com/api/trans/vip/translate'
|