Skip to content

Commit

Permalink
Update transcribe_audio.py
Browse files Browse the repository at this point in the history
* Changed the microphone list to show before gpu selection
* Web server will start after gpu selection
  • Loading branch information
cyberofficial committed Aug 8, 2023
1 parent 08b16d7 commit 481b2b0
Showing 1 changed file with 15 additions and 17 deletions.
32 changes: 15 additions & 17 deletions transcribe_audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@
def main():
args = parser_args.parse_arguments()

if args.portnumber:
print("Port number was set, so spinning up a web server...")
api_backend.flask_server(operation="start", portnumber=args.portnumber)

# if args.updatebranch is set as disable then skip
if args.updatebranch != "disable":
print("\nChecking for updates...")
Expand Down Expand Up @@ -88,7 +84,6 @@ def is_input_device(device_index):
from modules.version_checker import ScriptCreator, GitHubRepo
contributors(ScriptCreator, GitHubRepo)


model = parser_args.set_model_by_ram(args.ram, args.language)

hardmodel = None
Expand Down Expand Up @@ -136,6 +131,18 @@ def is_input_device(device_index):
print("WARNING: CUDA was chosen but it is not available. Falling back to CPU.")
print(f"Using device: {device}")

if args.list_microphones:
print("Available microphone devices are: ")
mic_table = PrettyTable()
mic_table.field_names = ["Index", "Microphone Name"]

for index, name in enumerate(sr.Microphone.list_microphone_names()):
if is_input_device(index):
mic_table.add_row([index, name])

print(mic_table)
sys.exit(0)

if device.type == "cuda":
# Check if multiple CUDA devices are available
cuda_device_count = torch.cuda.device_count()
Expand All @@ -159,18 +166,9 @@ def is_input_device(device_index):
print(f"CUDA device name: {torch.cuda.get_device_name(torch.cuda.current_device())}")
print(f"VRAM available: {torch.cuda.get_device_properties(torch.cuda.current_device()).total_memory / 1024 / 1024} MB")


if args.list_microphones:
print("Available microphone devices are: ")
mic_table = PrettyTable()
mic_table.field_names = ["Index", "Microphone Name"]

for index, name in enumerate(sr.Microphone.list_microphone_names()):
if is_input_device(index):
mic_table.add_row([index, name])

print(mic_table)
sys.exit(0)
if args.portnumber:
print("Port number was set, so spinning up a web server...")
api_backend.flask_server(operation="start", portnumber=args.portnumber)

try:
source, mic_name = get_microphone_source(args)
Expand Down

0 comments on commit 481b2b0

Please sign in to comment.