ipid commited on
Commit
d9165a1
1 Parent(s): 8b34879

Allow configuration of server port

Browse files
Files changed (2) hide show
  1. app-network.py +11 -1
  2. app.py +2 -2
app-network.py CHANGED
@@ -1,3 +1,13 @@
 
 
 
 
 
 
 
 
 
 
1
  # Run the app with no audio file restrictions, and make it available on the network
2
  from app import create_ui
3
- create_ui(-1, server_name="0.0.0.0")
1
+ import sys
2
+
3
+ server_port = None
4
+ try:
5
+ if len(sys.argv) > 1:
6
+ server_port = int(sys.argv[1])
7
+ except ValueError:
8
+ print(f'Usage: python {sys.argv[0]} <server-port>\n')
9
+ exit(1)
10
+
11
  # Run the app with no audio file restrictions, and make it available on the network
12
  from app import create_ui
13
+ create_ui(-1, server_name="0.0.0.0", server_port=server_port)
app.py CHANGED
@@ -220,7 +220,7 @@ class WhisperTranscriber:
220
  return file.name
221
 
222
 
223
- def create_ui(inputAudioMaxDuration, share=False, server_name: str = None):
224
  ui = WhisperTranscriber(inputAudioMaxDuration)
225
 
226
  ui_description = "Whisper is a general-purpose speech recognition model. It is trained on a large dataset of diverse "
@@ -253,7 +253,7 @@ def create_ui(inputAudioMaxDuration, share=False, server_name: str = None):
253
  gr.Text(label="Segments")
254
  ])
255
 
256
- demo.launch(share=share, server_name=server_name)
257
 
258
  if __name__ == '__main__':
259
  create_ui(DEFAULT_INPUT_AUDIO_MAX_DURATION)
220
  return file.name
221
 
222
 
223
+ def create_ui(inputAudioMaxDuration, share=False, server_name: str = None, server_port: int = None):
224
  ui = WhisperTranscriber(inputAudioMaxDuration)
225
 
226
  ui_description = "Whisper is a general-purpose speech recognition model. It is trained on a large dataset of diverse "
253
  gr.Text(label="Segments")
254
  ])
255
 
256
+ demo.launch(share=share, server_name=server_name, server_port=server_port)
257
 
258
  if __name__ == '__main__':
259
  create_ui(DEFAULT_INPUT_AUDIO_MAX_DURATION)