feat: runtime example

This commit is contained in:
Dan Chen
2024-03-21 18:12:32 +08:00
parent 1a3e6537a4
commit 4fe22fb7a0
2 changed files with 12 additions and 7 deletions

View File

@ -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

Binary file not shown.