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

Binary file not shown.