Skip to content

Commit

Permalink
http(s) are not supported media when ffmpeg is disabled ; fixed pyro …
Browse files Browse the repository at this point in the history
…client
  • Loading branch information
valentinp72 committed Nov 29, 2024
1 parent d0b9a19 commit cd39137
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
8 changes: 7 additions & 1 deletion inaSpeechSegmenter/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,17 @@ def media2sig16kmono(medianame, tmpdir=None, start_sec=None, stop_sec=None, ffmp
f'inaSpeechSegmenter without ffmpeg. Please cut down your ' \
f'audio files beforehand or use ffmpeg.'
)
if medianame.startswith('http://') or medianame.startswith('https://'):
raise NotImplementedError(
f'Without ffmpeg you cannot process media content on http ' \
f'servers. You need to download your audio files beforehand ' \
f'or use ffmpeg. You gave {medianame=}.'
)

sig, sr = sf.read(medianame, dtype=dtype)
assert sr == 16_000, \
f'Without ffmpeg, inaSpeechSegmenter can only take files sampled ' \
f'at 16000 Hz. The file {medianame} is sampled at {sr}.'
f'at 16000 Hz. The file {medianame} is sampled at {sr} Hz.'
return sig

base, _ = os.path.splitext(os.path.basename(medianame))
Expand Down
5 changes: 2 additions & 3 deletions scripts/ina_speech_segmenter_pyro_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,13 @@
import socket

import argparse
from inaSpeechSegmenter import Segmenter


if __name__ == '__main__':
parser = argparse.ArgumentParser(
description='Start a inaSpeechSegmenter Pyro client.'
)
parser.add_argument(
'uri', type=str, required=True,
'uri', type=str,
help='URI of the Pyro server to connect and get jobs from.'
)
parser.add_argument(
Expand All @@ -62,6 +60,7 @@
outname = 'init'

# batch size set at 1024. Use lower values with small gpus
from inaSpeechSegmenter import Segmenter
g = Segmenter(batch_size=args.batch_size, ffmpeg=args.ffmpeg_binary)

while True:
Expand Down

0 comments on commit cd39137

Please sign in to comment.