forked from kyutai-labs/moshi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_mimi.py
36 lines (28 loc) · 975 Bytes
/
test_mimi.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# Copyright (c) Kyutai, all rights reserved.
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import argparse
import numpy as np
import time
import rustymimi
def main():
parser = argparse.ArgumentParser()
parser.add_argument("--model", type=str)
parser.add_argument("--steps", default=100, type=int)
args = parser.parse_args()
steps = args.steps
model = rustymimi.Tokenizer(str(args.model))
print(model)
start_time = 0
for i in range(steps + 1):
if i == 1:
start_time = time.time()
pcm_data = np.array([[[0.0] * 1920]]).astype(np.float32)
out = model.encode_step(pcm_data)
print(out.shape)
pcm_data = model.decode_step(out)
print(pcm_data)
token_per_second = steps / (time.time() - start_time)
print(f"steps: {steps}, token per sec: {token_per_second}")
if __name__ == "__main__":
main()