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
|
from runtime.ast.runtime import Runtime
|
||||||
|
|
||||||
script = """
|
script = """
|
||||||
let hello = add(div(1,2),2)
|
let text = audio_to_text(audio)
|
||||||
|
return tts(text)
|
||||||
return hello
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def version():
|
def version():
|
||||||
return "0.0.1"
|
return "0.0.1"
|
||||||
|
|
||||||
def add(a,b):
|
def add(*args):
|
||||||
return a+b
|
return sum(args)
|
||||||
|
|
||||||
def div(a,b):
|
def div(a,b):
|
||||||
return a/b
|
return a/b
|
||||||
@ -43,5 +42,11 @@ if __name__ == "__main__":
|
|||||||
})
|
})
|
||||||
ast = Parser().parse(script)
|
ast = Parser().parse(script)
|
||||||
# 注入數據
|
# 注入數據
|
||||||
script_output = runtime.run(ast, {})
|
script_output = runtime.run(ast, {
|
||||||
print("script:",script_output)
|
"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