mirror of
https://github.com/BoardWare-Genius/jarvis-models.git
synced 2025-12-13 16:53:24 +00:00
feat: runtime example
This commit is contained in:
@ -4,16 +4,15 @@ from runtime.ast.parser import Parser
|
||||
from runtime.ast.runtime import Runtime
|
||||
|
||||
script = """
|
||||
let hello = add(div(1,2),2)
|
||||
|
||||
return hello
|
||||
let text = audio_to_text(audio)
|
||||
return tts(text)
|
||||
"""
|
||||
|
||||
def version():
|
||||
return "0.0.1"
|
||||
|
||||
def add(a,b):
|
||||
return a+b
|
||||
def add(*args):
|
||||
return sum(args)
|
||||
|
||||
def div(a,b):
|
||||
return a/b
|
||||
@ -43,5 +42,11 @@ if __name__ == "__main__":
|
||||
})
|
||||
ast = Parser().parse(script)
|
||||
# 注入數據
|
||||
script_output = runtime.run(ast, {})
|
||||
print("script:",script_output)
|
||||
script_output = runtime.run(ast, {
|
||||
"audio": audio_data,
|
||||
})
|
||||
f = open("./test_data/tmp.wav", "wb")
|
||||
print("script:", type(script_output))
|
||||
f.write(script_output.read())
|
||||
f.close()
|
||||
|
||||
BIN
test_data/tmp.wav
Normal file
BIN
test_data/tmp.wav
Normal file
Binary file not shown.
Reference in New Issue
Block a user