Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add device option in wespeaker cli; set onnxruntime log level #351

Merged
merged 2 commits into from
Aug 23, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions wespeaker/cli/speaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,7 @@ def set_resample_rate(self, resample_rate: int):
def set_vad(self, apply_vad: bool):
self.apply_vad = apply_vad

def set_gpu(self, device_id: int):
if device_id >= 0:
device = 'cuda:{}'.format(device_id)
else:
device = 'cpu'
def set_device(self, device: str):
self.device = torch.device(device)
self.model = self.model.to(self.device)

Expand Down Expand Up @@ -304,7 +300,7 @@ def main():
model = load_model_local(args.pretrain)
model.set_resample_rate(args.resample_rate)
model.set_vad(args.vad)
model.set_gpu(args.gpu)
model.set_device(args.device)
model.set_diarization_params(min_duration=args.diar_min_duration,
window_secs=args.diar_window_secs,
period_secs=args.diar_period_secs,
Expand Down
11 changes: 6 additions & 5 deletions wespeaker/cli/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,12 @@ def get_args():
type=str,
default="",
help='model directory')
parser.add_argument('-g',
'--gpu',
type=int,
default=-1,
help='which gpu to use (number <0 means using cpu)')
parser.add_argument('--device',
type=str,
default='cpu',
help="device type (most commonly cpu or cuda,"
"but also potentially mps, xpu, xla or meta)"
"and optional device ordinal for the device type.")
parser.add_argument('--audio_file', help='audio file')
parser.add_argument('--audio_file2',
help='audio file2, specifically for similarity task')
Expand Down
2 changes: 1 addition & 1 deletion wespeaker/diar/extract_emb.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def init_session(source, device):
opts = ort.SessionOptions()
opts.inter_op_num_threads = 1
opts.intra_op_num_threads = 1
opts.log_severity_level = 0
opts.log_severity_level = 1
session = ort.InferenceSession(source,
sess_options=opts,
providers=providers)
Expand Down
Loading