File size: 1,113 Bytes
2c04fa5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import os
import streamlit.components.v1 as components

_RELEASE = True

if not _RELEASE:
    _component_func = components.declare_component(
        "model_demo",
        url="http://localhost:3001",
    )
else:
    # When we're distributing a production version of the component, we'll
    # replace the `url` param with `path`, and point it to the component's
    # build directory:
    parent_dir = os.path.dirname(os.path.abspath(__file__))
    build_dir = os.path.join(parent_dir, "frontend/build")
    _component_func = components.declare_component("model_demo", path=build_dir)


def model_demo(
    blendshapes=None, headangles=None, audio_data=None, vrm_data=None, key=None
):
    component_value = _component_func(
        blendshapes=blendshapes.tolist() if blendshapes is not None else None,
        headangles=headangles.tolist() if headangles is not None else None,
        audio_data=audio_data.decode("latin1") if audio_data is not None else None,
        vrm_data=[int(b) for b in vrm_data] if vrm_data is not None else None,
        key=key,
        default=0,
    )
    return component_value