Spaces:
Running
Running
Update utils.py
Browse files
utils.py
CHANGED
@@ -1,3 +1,4 @@
|
|
|
|
1 |
import io
|
2 |
|
3 |
import librosa
|
@@ -57,15 +58,19 @@ def bytes_to_array(audio_bytes):
|
|
57 |
)
|
58 |
return audio_array
|
59 |
|
60 |
-
def start_server(
|
61 |
-
|
|
|
|
|
|
|
62 |
|
63 |
server = SSHTunnelForwarder(
|
64 |
-
ssh_address_or_host=
|
65 |
ssh_username="ec2-user",
|
66 |
ssh_pkey=pkey,
|
67 |
-
local_bind_address=("127.0.0.1",
|
68 |
remote_bind_address=("127.0.0.1", 8000)
|
69 |
)
|
70 |
-
|
|
|
71 |
server.start()
|
|
|
1 |
+
import os
|
2 |
import io
|
3 |
|
4 |
import librosa
|
|
|
58 |
)
|
59 |
return audio_array
|
60 |
|
61 |
+
def start_server():
|
62 |
+
if os.getenv('TUNNEL_STATUS') == "200":
|
63 |
+
return
|
64 |
+
|
65 |
+
pkey = paramiko.RSAKey.from_private_key(io.StringIO(os.getenv('PRIVATE_KEY')))
|
66 |
|
67 |
server = SSHTunnelForwarder(
|
68 |
+
ssh_address_or_host=os.getenv('SERVER_DNS_NAME'),
|
69 |
ssh_username="ec2-user",
|
70 |
ssh_pkey=pkey,
|
71 |
+
local_bind_address=("127.0.0.1", int(os.getenv('LOCAL_PORT'))),
|
72 |
remote_bind_address=("127.0.0.1", 8000)
|
73 |
)
|
74 |
+
|
75 |
+
os.environ['TUNNEL_STATUS'] = "200"
|
76 |
server.start()
|