Add --num_block option

This commit is contained in:
Yuta Hayashibe 2022-09-23 20:45:18 +09:00
parent 957a3ffe18
commit c97134a45f

View file

@ -21,6 +21,7 @@ def transcribe_from_mic(
*, *,
config: WhisperConfig, config: WhisperConfig,
sd_device: Optional[Union[int, str]], sd_device: Optional[Union[int, str]],
num_block: int,
) -> None: ) -> None:
wsp = WhisperStreamingTranscriber(config=config) wsp = WhisperStreamingTranscriber(config=config)
q = queue.Queue() q = queue.Queue()
@ -33,7 +34,7 @@ def transcribe_from_mic(
logger.info("Ready to transcribe") logger.info("Ready to transcribe")
with sd.InputStream( with sd.InputStream(
samplerate=SAMPLE_RATE, samplerate=SAMPLE_RATE,
blocksize=N_FRAMES * 10, # FIXME blocksize=N_FRAMES * num_block,
device=sd_device, device=sd_device,
dtype="float32", dtype="float32",
channels=1, channels=1,
@ -72,6 +73,13 @@ def get_opts() -> argparse.Namespace:
type=int, type=int,
default=5, default=5,
) )
parser.add_argument(
"--num_block",
"-b",
type=int,
default=20,
help="Number of operation unit. Larger values can improve accuracy but consume more memory.",
)
parser.add_argument( parser.add_argument(
"--mic", "--mic",
) )
@ -98,6 +106,7 @@ def main() -> None:
transcribe_from_mic( transcribe_from_mic(
config=config, config=config,
sd_device=opts.mic, sd_device=opts.mic,
num_block=opts.num_block,
) )