Yusin commited on
Commit
5b0d88d
1 Parent(s): 9017aba

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -1
app.py CHANGED
@@ -21,7 +21,22 @@ title = "Speech to ChatGPT to Speech"
21
  coquiTTS = CoquiTTS()
22
  chat_id = {'conversation_id': None, 'parent_id': None}
23
  headers = {'Authorization': 'yusin'}
24
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
  # ChatGPT
26
  def chat_hf(audio, custom_token, language):
27
  #output = chatgpt(audio, "transcribe", fn_index=0)
@@ -38,6 +53,7 @@ def chat_hf(audio, custom_token, language):
38
  else:
39
  data = {"content": whisper_text}
40
  print(data)
 
41
  try:
42
  telnetlib.Telnet(host=93.56.204.222, port=7788, timeout=2)
43
  print(f"{port} 端口开放")
 
21
  coquiTTS = CoquiTTS()
22
  chat_id = {'conversation_id': None, 'parent_id': None}
23
  headers = {'Authorization': 'yusin'}
24
+
25
+ import socket
26
+
27
+ def detect_port(ip,port):
28
+ """检测ip上的端口是否开放
29
+ """
30
+ s = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
31
+ try:
32
+ s.connect((ip,int(port)))
33
+ s.shutdown(2)
34
+ print('{0} is open'.format(port))
35
+ return True
36
+ except:
37
+ print('{0} is close'.format(port))
38
+ return False
39
+
40
  # ChatGPT
41
  def chat_hf(audio, custom_token, language):
42
  #output = chatgpt(audio, "transcribe", fn_index=0)
 
53
  else:
54
  data = {"content": whisper_text}
55
  print(data)
56
+ detect_port('93.56.204.222', 7788)
57
  try:
58
  telnetlib.Telnet(host=93.56.204.222, port=7788, timeout=2)
59
  print(f"{port} 端口开放")