├── .env.example ├── .eslintrc.json ├── .github ├── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md └── workflows │ └── publish.yml ├── .gitignore ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── SECURITY.md ├── assets ├── animations │ ├── bored │ │ ├── female-pose-standing.glb │ │ ├── male-pose-standing.glb │ │ ├── rumba-dance.fbx │ │ ├── yawn.fbx │ │ ├── yelling.fbx │ │ └── ymca.fbx │ ├── greet │ │ └── greet-1.fbx │ ├── idle │ │ ├── idle-1.fbx │ │ ├── idle-2.fbx │ │ ├── idle-3.fbx │ │ └── idle-4.fbx │ ├── talk │ │ ├── talk-1.fbx │ │ ├── talk-2.fbx │ │ └── talk-3.fbx │ └── walk │ │ ├── walk-1.fbx │ │ └── walk-2.fbx ├── images │ └── lalaland.png └── vrms │ └── lala.vrm ├── forge.config.ts ├── package-lock.json ├── package.json ├── src ├── App.tsx ├── Scene.tsx ├── components │ └── VRMCompanion.tsx ├── constants │ └── animations.ts ├── helpers │ ├── loadMixamoAnimation.js │ └── mixamoVRMRigMap.ts ├── index.css ├── index.html ├── main.ts ├── overlay │ ├── Overlay.tsx │ ├── index.html │ └── renderer.ts ├── preload.ts ├── renderer.ts ├── theme.ts └── types.d.ts ├── tsconfig.json ├── webpack.main.config.ts ├── webpack.plugins.ts ├── webpack.renderer.config.ts └── webpack.rules.ts /.env.example: -------------------------------------------------------------------------------- 1 | GITHUB_TOKEN = 2 | OPENAI_API_KEY = -------------------------------------------------------------------------------- /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "browser": true, 4 | "es6": true, 5 | "node": true 6 | }, 7 | "extends": [ 8 | "eslint:recommended", 9 | "plugin:@typescript-eslint/eslint-recommended", 10 | "plugin:@typescript-eslint/recommended", 11 | "plugin:import/recommended", 12 | "plugin:import/electron", 13 | "plugin:import/typescript" 14 | ], 15 | "parser": "@typescript-eslint/parser" 16 | } 17 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: bug 6 | assignees: ChristopherTrimboli 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. Go to '...' 16 | 2. Click on '....' 17 | 3. Scroll down to '....' 18 | 4. See error 19 | 20 | **Expected behavior** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Screenshots** 24 | If applicable, add screenshots to help explain your problem. 25 | 26 | **Desktop (please complete the following information):** 27 | - OS: [e.g. iOS] 28 | - Browser [e.g. chrome, safari] 29 | - Version [e.g. 22] 30 | 31 | **Smartphone (please complete the following information):** 32 | - Device: [e.g. iPhone6] 33 | - OS: [e.g. iOS8.1] 34 | - Browser [e.g. stock browser, safari] 35 | - Version [e.g. 22] 36 | 37 | **Additional context** 38 | Add any other context about the problem here. 39 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: enhancement 6 | assignees: ChristopherTrimboli 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.github/workflows/publish.yml: -------------------------------------------------------------------------------- 1 | on: 2 | push: 3 | branches: 4 | - main 5 | jobs: 6 | publish: 7 | strategy: 8 | matrix: 9 | os: [ubuntu-latest, windows-latest, macos-latest] 10 | version: [23.x] 11 | runs-on: ${{ matrix.os }} 12 | steps: 13 | - uses: actions/setup-node@v4 14 | with: 15 | node-version: ${{ matrix.version }} 16 | - uses: actions/checkout@v4 17 | - run: npm ci 18 | - run: npm run publish 19 | env: 20 | GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} 21 | NODE_OPTIONS: "--no-experimental-strip-types" -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | lerna-debug.log* 8 | 9 | # Diagnostic reports (https://nodejs.org/api/report.html) 10 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 11 | 12 | # Runtime data 13 | pids 14 | *.pid 15 | *.seed 16 | *.pid.lock 17 | .DS_Store 18 | 19 | # Directory for instrumented libs generated by jscoverage/JSCover 20 | lib-cov 21 | 22 | # Coverage directory used by tools like istanbul 23 | coverage 24 | *.lcov 25 | 26 | # nyc test coverage 27 | .nyc_output 28 | 29 | # node-waf configuration 30 | .lock-wscript 31 | 32 | # Compiled binary addons (https://nodejs.org/api/addons.html) 33 | build/Release 34 | 35 | # Dependency directories 36 | node_modules 37 | jspm_packages/ 38 | 39 | # TypeScript v1 declaration files 40 | typings/ 41 | 42 | # TypeScript cache 43 | *.tsbuildinfo 44 | 45 | # Optional npm cache directory 46 | .npm 47 | 48 | # Optional eslint cache 49 | .eslintcache 50 | 51 | # Optional REPL history 52 | .node_repl_history 53 | 54 | # Output of 'npm pack' 55 | *.tgz 56 | 57 | # Yarn Integrity file 58 | .yarn-integrity 59 | 60 | # dotenv environment variables file 61 | .env 62 | .env.test 63 | 64 | # parcel-bundler cache (https://parceljs.org/) 65 | .cache 66 | 67 | # next.js build output 68 | .next 69 | 70 | # nuxt.js build output 71 | .nuxt 72 | 73 | # vuepress build output 74 | .vuepress/dist 75 | 76 | # Serverless directories 77 | .serverless/ 78 | 79 | # FuseBox cache 80 | .fusebox/ 81 | 82 | # DynamoDB Local files 83 | .dynamodb/ 84 | 85 | # Webpack 86 | .webpack/ 87 | 88 | # Vite 89 | .vite/ 90 | 91 | # Electron-Forge 92 | out/ 93 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | We as members, contributors, and leaders pledge to make participation in our 6 | community a harassment-free experience for everyone, regardless of age, body 7 | size, visible or invisible disability, ethnicity, sex characteristics, gender 8 | identity and expression, level of experience, education, socio-economic status, 9 | nationality, personal appearance, race, religion, or sexual identity 10 | and orientation. 11 | 12 | We pledge to act and interact in ways that contribute to an open, welcoming, 13 | diverse, inclusive, and healthy community. 14 | 15 | ## Our Standards 16 | 17 | Examples of behavior that contributes to a positive environment for our 18 | community include: 19 | 20 | * Demonstrating empathy and kindness toward other people 21 | * Being respectful of differing opinions, viewpoints, and experiences 22 | * Giving and gracefully accepting constructive feedback 23 | * Accepting responsibility and apologizing to those affected by our mistakes, 24 | and learning from the experience 25 | * Focusing on what is best not just for us as individuals, but for the 26 | overall community 27 | 28 | Examples of unacceptable behavior include: 29 | 30 | * The use of sexualized language or imagery, and sexual attention or 31 | advances of any kind 32 | * Trolling, insulting or derogatory comments, and personal or political attacks 33 | * Public or private harassment 34 | * Publishing others' private information, such as a physical or email 35 | address, without their explicit permission 36 | * Other conduct which could reasonably be considered inappropriate in a 37 | professional setting 38 | 39 | ## Enforcement Responsibilities 40 | 41 | Community leaders are responsible for clarifying and enforcing our standards of 42 | acceptable behavior and will take appropriate and fair corrective action in 43 | response to any behavior that they deem inappropriate, threatening, offensive, 44 | or harmful. 45 | 46 | Community leaders have the right and responsibility to remove, edit, or reject 47 | comments, commits, code, wiki edits, issues, and other contributions that are 48 | not aligned to this Code of Conduct, and will communicate reasons for moderation 49 | decisions when appropriate. 50 | 51 | ## Scope 52 | 53 | This Code of Conduct applies within all community spaces, and also applies when 54 | an individual is officially representing the community in public spaces. 55 | Examples of representing our community include using an official e-mail address, 56 | posting via an official social media account, or acting as an appointed 57 | representative at an online or offline event. 58 | 59 | ## Enforcement 60 | 61 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 62 | reported to the community leaders responsible for enforcement at 63 | cjft@trimboli.io. 64 | All complaints will be reviewed and investigated promptly and fairly. 65 | 66 | All community leaders are obligated to respect the privacy and security of the 67 | reporter of any incident. 68 | 69 | ## Enforcement Guidelines 70 | 71 | Community leaders will follow these Community Impact Guidelines in determining 72 | the consequences for any action they deem in violation of this Code of Conduct: 73 | 74 | ### 1. Correction 75 | 76 | **Community Impact**: Use of inappropriate language or other behavior deemed 77 | unprofessional or unwelcome in the community. 78 | 79 | **Consequence**: A private, written warning from community leaders, providing 80 | clarity around the nature of the violation and an explanation of why the 81 | behavior was inappropriate. A public apology may be requested. 82 | 83 | ### 2. Warning 84 | 85 | **Community Impact**: A violation through a single incident or series 86 | of actions. 87 | 88 | **Consequence**: A warning with consequences for continued behavior. No 89 | interaction with the people involved, including unsolicited interaction with 90 | those enforcing the Code of Conduct, for a specified period of time. This 91 | includes avoiding interactions in community spaces as well as external channels 92 | like social media. Violating these terms may lead to a temporary or 93 | permanent ban. 94 | 95 | ### 3. Temporary Ban 96 | 97 | **Community Impact**: A serious violation of community standards, including 98 | sustained inappropriate behavior. 99 | 100 | **Consequence**: A temporary ban from any sort of interaction or public 101 | communication with the community for a specified period of time. No public or 102 | private interaction with the people involved, including unsolicited interaction 103 | with those enforcing the Code of Conduct, is allowed during this period. 104 | Violating these terms may lead to a permanent ban. 105 | 106 | ### 4. Permanent Ban 107 | 108 | **Community Impact**: Demonstrating a pattern of violation of community 109 | standards, including sustained inappropriate behavior, harassment of an 110 | individual, or aggression toward or disparagement of classes of individuals. 111 | 112 | **Consequence**: A permanent ban from any sort of public interaction within 113 | the community. 114 | 115 | ## Attribution 116 | 117 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], 118 | version 2.0, available at 119 | https://www.contributor-covenant.org/version/2/0/code_of_conduct.html. 120 | 121 | Community Impact Guidelines were inspired by [Mozilla's code of conduct 122 | enforcement ladder](https://github.com/mozilla/diversity). 123 | 124 | [homepage]: https://www.contributor-covenant.org 125 | 126 | For answers to common questions about this code of conduct, see the FAQ at 127 | https://www.contributor-covenant.org/faq. Translations are available at 128 | https://www.contributor-covenant.org/translations. 129 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | Wanna fix a bug or add a new feature? Go ahead, make a PR. We don't care how pretty the PR template is, code quality must be AAA metagod status only however. 2 | Have a question, go ahead and ask. 3 | Idea? Our ears are open, pitch it. 4 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU AFFERO GENERAL PUBLIC LICENSE 2 | Version 3, 19 November 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU Affero General Public License is a free, copyleft license for 11 | software and other kinds of works, specifically designed to ensure 12 | cooperation with the community in the case of network server software. 13 | 14 | The licenses for most software and other practical works are designed 15 | to take away your freedom to share and change the works. By contrast, 16 | our General Public Licenses are intended to guarantee your freedom to 17 | share and change all versions of a program--to make sure it remains free 18 | software for all its users. 19 | 20 | When we speak of free software, we are referring to freedom, not 21 | price. Our General Public Licenses are designed to make sure that you 22 | have the freedom to distribute copies of free software (and charge for 23 | them if you wish), that you receive source code or can get it if you 24 | want it, that you can change the software or use pieces of it in new 25 | free programs, and that you know you can do these things. 26 | 27 | Developers that use our General Public Licenses protect your rights 28 | with two steps: (1) assert copyright on the software, and (2) offer 29 | you this License which gives you legal permission to copy, distribute 30 | and/or modify the software. 31 | 32 | A secondary benefit of defending all users' freedom is that 33 | improvements made in alternate versions of the program, if they 34 | receive widespread use, become available for other developers to 35 | incorporate. Many developers of free software are heartened and 36 | encouraged by the resulting cooperation. However, in the case of 37 | software used on network servers, this result may fail to come about. 38 | The GNU General Public License permits making a modified version and 39 | letting the public access it on a server without ever releasing its 40 | source code to the public. 41 | 42 | The GNU Affero General Public License is designed specifically to 43 | ensure that, in such cases, the modified source code becomes available 44 | to the community. It requires the operator of a network server to 45 | provide the source code of the modified version running there to the 46 | users of that server. Therefore, public use of a modified version, on 47 | a publicly accessible server, gives the public access to the source 48 | code of the modified version. 49 | 50 | An older license, called the Affero General Public License and 51 | published by Affero, was designed to accomplish similar goals. This is 52 | a different license, not a version of the Affero GPL, but Affero has 53 | released a new version of the Affero GPL which permits relicensing under 54 | this license. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | TERMS AND CONDITIONS 60 | 61 | 0. Definitions. 62 | 63 | "This License" refers to version 3 of the GNU Affero General Public License. 64 | 65 | "Copyright" also means copyright-like laws that apply to other kinds of 66 | works, such as semiconductor masks. 67 | 68 | "The Program" refers to any copyrightable work licensed under this 69 | License. Each licensee is addressed as "you". "Licensees" and 70 | "recipients" may be individuals or organizations. 71 | 72 | To "modify" a work means to copy from or adapt all or part of the work 73 | in a fashion requiring copyright permission, other than the making of an 74 | exact copy. The resulting work is called a "modified version" of the 75 | earlier work or a work "based on" the earlier work. 76 | 77 | A "covered work" means either the unmodified Program or a work based 78 | on the Program. 79 | 80 | To "propagate" a work means to do anything with it that, without 81 | permission, would make you directly or secondarily liable for 82 | infringement under applicable copyright law, except executing it on a 83 | computer or modifying a private copy. Propagation includes copying, 84 | distribution (with or without modification), making available to the 85 | public, and in some countries other activities as well. 86 | 87 | To "convey" a work means any kind of propagation that enables other 88 | parties to make or receive copies. Mere interaction with a user through 89 | a computer network, with no transfer of a copy, is not conveying. 90 | 91 | An interactive user interface displays "Appropriate Legal Notices" 92 | to the extent that it includes a convenient and prominently visible 93 | feature that (1) displays an appropriate copyright notice, and (2) 94 | tells the user that there is no warranty for the work (except to the 95 | extent that warranties are provided), that licensees may convey the 96 | work under this License, and how to view a copy of this License. If 97 | the interface presents a list of user commands or options, such as a 98 | menu, a prominent item in the list meets this criterion. 99 | 100 | 1. Source Code. 101 | 102 | The "source code" for a work means the preferred form of the work 103 | for making modifications to it. "Object code" means any non-source 104 | form of a work. 105 | 106 | A "Standard Interface" means an interface that either is an official 107 | standard defined by a recognized standards body, or, in the case of 108 | interfaces specified for a particular programming language, one that 109 | is widely used among developers working in that language. 110 | 111 | The "System Libraries" of an executable work include anything, other 112 | than the work as a whole, that (a) is included in the normal form of 113 | packaging a Major Component, but which is not part of that Major 114 | Component, and (b) serves only to enable use of the work with that 115 | Major Component, or to implement a Standard Interface for which an 116 | implementation is available to the public in source code form. A 117 | "Major Component", in this context, means a major essential component 118 | (kernel, window system, and so on) of the specific operating system 119 | (if any) on which the executable work runs, or a compiler used to 120 | produce the work, or an object code interpreter used to run it. 121 | 122 | The "Corresponding Source" for a work in object code form means all 123 | the source code needed to generate, install, and (for an executable 124 | work) run the object code and to modify the work, including scripts to 125 | control those activities. However, it does not include the work's 126 | System Libraries, or general-purpose tools or generally available free 127 | programs which are used unmodified in performing those activities but 128 | which are not part of the work. For example, Corresponding Source 129 | includes interface definition files associated with source files for 130 | the work, and the source code for shared libraries and dynamically 131 | linked subprograms that the work is specifically designed to require, 132 | such as by intimate data communication or control flow between those 133 | subprograms and other parts of the work. 134 | 135 | The Corresponding Source need not include anything that users 136 | can regenerate automatically from other parts of the Corresponding 137 | Source. 138 | 139 | The Corresponding Source for a work in source code form is that 140 | same work. 141 | 142 | 2. Basic Permissions. 143 | 144 | All rights granted under this License are granted for the term of 145 | copyright on the Program, and are irrevocable provided the stated 146 | conditions are met. This License explicitly affirms your unlimited 147 | permission to run the unmodified Program. The output from running a 148 | covered work is covered by this License only if the output, given its 149 | content, constitutes a covered work. This License acknowledges your 150 | rights of fair use or other equivalent, as provided by copyright law. 151 | 152 | You may make, run and propagate covered works that you do not 153 | convey, without conditions so long as your license otherwise remains 154 | in force. You may convey covered works to others for the sole purpose 155 | of having them make modifications exclusively for you, or provide you 156 | with facilities for running those works, provided that you comply with 157 | the terms of this License in conveying all material for which you do 158 | not control copyright. Those thus making or running the covered works 159 | for you must do so exclusively on your behalf, under your direction 160 | and control, on terms that prohibit them from making any copies of 161 | your copyrighted material outside their relationship with you. 162 | 163 | Conveying under any other circumstances is permitted solely under 164 | the conditions stated below. Sublicensing is not allowed; section 10 165 | makes it unnecessary. 166 | 167 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 168 | 169 | No covered work shall be deemed part of an effective technological 170 | measure under any applicable law fulfilling obligations under article 171 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 172 | similar laws prohibiting or restricting circumvention of such 173 | measures. 174 | 175 | When you convey a covered work, you waive any legal power to forbid 176 | circumvention of technological measures to the extent such circumvention 177 | is effected by exercising rights under this License with respect to 178 | the covered work, and you disclaim any intention to limit operation or 179 | modification of the work as a means of enforcing, against the work's 180 | users, your or third parties' legal rights to forbid circumvention of 181 | technological measures. 182 | 183 | 4. Conveying Verbatim Copies. 184 | 185 | You may convey verbatim copies of the Program's source code as you 186 | receive it, in any medium, provided that you conspicuously and 187 | appropriately publish on each copy an appropriate copyright notice; 188 | keep intact all notices stating that this License and any 189 | non-permissive terms added in accord with section 7 apply to the code; 190 | keep intact all notices of the absence of any warranty; and give all 191 | recipients a copy of this License along with the Program. 192 | 193 | You may charge any price or no price for each copy that you convey, 194 | and you may offer support or warranty protection for a fee. 195 | 196 | 5. Conveying Modified Source Versions. 197 | 198 | You may convey a work based on the Program, or the modifications to 199 | produce it from the Program, in the form of source code under the 200 | terms of section 4, provided that you also meet all of these conditions: 201 | 202 | a) The work must carry prominent notices stating that you modified 203 | it, and giving a relevant date. 204 | 205 | b) The work must carry prominent notices stating that it is 206 | released under this License and any conditions added under section 207 | 7. This requirement modifies the requirement in section 4 to 208 | "keep intact all notices". 209 | 210 | c) You must license the entire work, as a whole, under this 211 | License to anyone who comes into possession of a copy. This 212 | License will therefore apply, along with any applicable section 7 213 | additional terms, to the whole of the work, and all its parts, 214 | regardless of how they are packaged. This License gives no 215 | permission to license the work in any other way, but it does not 216 | invalidate such permission if you have separately received it. 217 | 218 | d) If the work has interactive user interfaces, each must display 219 | Appropriate Legal Notices; however, if the Program has interactive 220 | interfaces that do not display Appropriate Legal Notices, your 221 | work need not make them do so. 222 | 223 | A compilation of a covered work with other separate and independent 224 | works, which are not by their nature extensions of the covered work, 225 | and which are not combined with it such as to form a larger program, 226 | in or on a volume of a storage or distribution medium, is called an 227 | "aggregate" if the compilation and its resulting copyright are not 228 | used to limit the access or legal rights of the compilation's users 229 | beyond what the individual works permit. Inclusion of a covered work 230 | in an aggregate does not cause this License to apply to the other 231 | parts of the aggregate. 232 | 233 | 6. Conveying Non-Source Forms. 234 | 235 | You may convey a covered work in object code form under the terms 236 | of sections 4 and 5, provided that you also convey the 237 | machine-readable Corresponding Source under the terms of this License, 238 | in one of these ways: 239 | 240 | a) Convey the object code in, or embodied in, a physical product 241 | (including a physical distribution medium), accompanied by the 242 | Corresponding Source fixed on a durable physical medium 243 | customarily used for software interchange. 244 | 245 | b) Convey the object code in, or embodied in, a physical product 246 | (including a physical distribution medium), accompanied by a 247 | written offer, valid for at least three years and valid for as 248 | long as you offer spare parts or customer support for that product 249 | model, to give anyone who possesses the object code either (1) a 250 | copy of the Corresponding Source for all the software in the 251 | product that is covered by this License, on a durable physical 252 | medium customarily used for software interchange, for a price no 253 | more than your reasonable cost of physically performing this 254 | conveying of source, or (2) access to copy the 255 | Corresponding Source from a network server at no charge. 256 | 257 | c) Convey individual copies of the object code with a copy of the 258 | written offer to provide the Corresponding Source. This 259 | alternative is allowed only occasionally and noncommercially, and 260 | only if you received the object code with such an offer, in accord 261 | with subsection 6b. 262 | 263 | d) Convey the object code by offering access from a designated 264 | place (gratis or for a charge), and offer equivalent access to the 265 | Corresponding Source in the same way through the same place at no 266 | further charge. You need not require recipients to copy the 267 | Corresponding Source along with the object code. If the place to 268 | copy the object code is a network server, the Corresponding Source 269 | may be on a different server (operated by you or a third party) 270 | that supports equivalent copying facilities, provided you maintain 271 | clear directions next to the object code saying where to find the 272 | Corresponding Source. Regardless of what server hosts the 273 | Corresponding Source, you remain obligated to ensure that it is 274 | available for as long as needed to satisfy these requirements. 275 | 276 | e) Convey the object code using peer-to-peer transmission, provided 277 | you inform other peers where the object code and Corresponding 278 | Source of the work are being offered to the general public at no 279 | charge under subsection 6d. 280 | 281 | A separable portion of the object code, whose source code is excluded 282 | from the Corresponding Source as a System Library, need not be 283 | included in conveying the object code work. 284 | 285 | A "User Product" is either (1) a "consumer product", which means any 286 | tangible personal property which is normally used for personal, family, 287 | or household purposes, or (2) anything designed or sold for incorporation 288 | into a dwelling. In determining whether a product is a consumer product, 289 | doubtful cases shall be resolved in favor of coverage. For a particular 290 | product received by a particular user, "normally used" refers to a 291 | typical or common use of that class of product, regardless of the status 292 | of the particular user or of the way in which the particular user 293 | actually uses, or expects or is expected to use, the product. A product 294 | is a consumer product regardless of whether the product has substantial 295 | commercial, industrial or non-consumer uses, unless such uses represent 296 | the only significant mode of use of the product. 297 | 298 | "Installation Information" for a User Product means any methods, 299 | procedures, authorization keys, or other information required to install 300 | and execute modified versions of a covered work in that User Product from 301 | a modified version of its Corresponding Source. The information must 302 | suffice to ensure that the continued functioning of the modified object 303 | code is in no case prevented or interfered with solely because 304 | modification has been made. 305 | 306 | If you convey an object code work under this section in, or with, or 307 | specifically for use in, a User Product, and the conveying occurs as 308 | part of a transaction in which the right of possession and use of the 309 | User Product is transferred to the recipient in perpetuity or for a 310 | fixed term (regardless of how the transaction is characterized), the 311 | Corresponding Source conveyed under this section must be accompanied 312 | by the Installation Information. But this requirement does not apply 313 | if neither you nor any third party retains the ability to install 314 | modified object code on the User Product (for example, the work has 315 | been installed in ROM). 316 | 317 | The requirement to provide Installation Information does not include a 318 | requirement to continue to provide support service, warranty, or updates 319 | for a work that has been modified or installed by the recipient, or for 320 | the User Product in which it has been modified or installed. Access to a 321 | network may be denied when the modification itself materially and 322 | adversely affects the operation of the network or violates the rules and 323 | protocols for communication across the network. 324 | 325 | Corresponding Source conveyed, and Installation Information provided, 326 | in accord with this section must be in a format that is publicly 327 | documented (and with an implementation available to the public in 328 | source code form), and must require no special password or key for 329 | unpacking, reading or copying. 330 | 331 | 7. Additional Terms. 332 | 333 | "Additional permissions" are terms that supplement the terms of this 334 | License by making exceptions from one or more of its conditions. 335 | Additional permissions that are applicable to the entire Program shall 336 | be treated as though they were included in this License, to the extent 337 | that they are valid under applicable law. If additional permissions 338 | apply only to part of the Program, that part may be used separately 339 | under those permissions, but the entire Program remains governed by 340 | this License without regard to the additional permissions. 341 | 342 | When you convey a copy of a covered work, you may at your option 343 | remove any additional permissions from that copy, or from any part of 344 | it. (Additional permissions may be written to require their own 345 | removal in certain cases when you modify the work.) You may place 346 | additional permissions on material, added by you to a covered work, 347 | for which you have or can give appropriate copyright permission. 348 | 349 | Notwithstanding any other provision of this License, for material you 350 | add to a covered work, you may (if authorized by the copyright holders of 351 | that material) supplement the terms of this License with terms: 352 | 353 | a) Disclaiming warranty or limiting liability differently from the 354 | terms of sections 15 and 16 of this License; or 355 | 356 | b) Requiring preservation of specified reasonable legal notices or 357 | author attributions in that material or in the Appropriate Legal 358 | Notices displayed by works containing it; or 359 | 360 | c) Prohibiting misrepresentation of the origin of that material, or 361 | requiring that modified versions of such material be marked in 362 | reasonable ways as different from the original version; or 363 | 364 | d) Limiting the use for publicity purposes of names of licensors or 365 | authors of the material; or 366 | 367 | e) Declining to grant rights under trademark law for use of some 368 | trade names, trademarks, or service marks; or 369 | 370 | f) Requiring indemnification of licensors and authors of that 371 | material by anyone who conveys the material (or modified versions of 372 | it) with contractual assumptions of liability to the recipient, for 373 | any liability that these contractual assumptions directly impose on 374 | those licensors and authors. 375 | 376 | All other non-permissive additional terms are considered "further 377 | restrictions" within the meaning of section 10. If the Program as you 378 | received it, or any part of it, contains a notice stating that it is 379 | governed by this License along with a term that is a further 380 | restriction, you may remove that term. If a license document contains 381 | a further restriction but permits relicensing or conveying under this 382 | License, you may add to a covered work material governed by the terms 383 | of that license document, provided that the further restriction does 384 | not survive such relicensing or conveying. 385 | 386 | If you add terms to a covered work in accord with this section, you 387 | must place, in the relevant source files, a statement of the 388 | additional terms that apply to those files, or a notice indicating 389 | where to find the applicable terms. 390 | 391 | Additional terms, permissive or non-permissive, may be stated in the 392 | form of a separately written license, or stated as exceptions; 393 | the above requirements apply either way. 394 | 395 | 8. Termination. 396 | 397 | You may not propagate or modify a covered work except as expressly 398 | provided under this License. Any attempt otherwise to propagate or 399 | modify it is void, and will automatically terminate your rights under 400 | this License (including any patent licenses granted under the third 401 | paragraph of section 11). 402 | 403 | However, if you cease all violation of this License, then your 404 | license from a particular copyright holder is reinstated (a) 405 | provisionally, unless and until the copyright holder explicitly and 406 | finally terminates your license, and (b) permanently, if the copyright 407 | holder fails to notify you of the violation by some reasonable means 408 | prior to 60 days after the cessation. 409 | 410 | Moreover, your license from a particular copyright holder is 411 | reinstated permanently if the copyright holder notifies you of the 412 | violation by some reasonable means, this is the first time you have 413 | received notice of violation of this License (for any work) from that 414 | copyright holder, and you cure the violation prior to 30 days after 415 | your receipt of the notice. 416 | 417 | Termination of your rights under this section does not terminate the 418 | licenses of parties who have received copies or rights from you under 419 | this License. If your rights have been terminated and not permanently 420 | reinstated, you do not qualify to receive new licenses for the same 421 | material under section 10. 422 | 423 | 9. Acceptance Not Required for Having Copies. 424 | 425 | You are not required to accept this License in order to receive or 426 | run a copy of the Program. Ancillary propagation of a covered work 427 | occurring solely as a consequence of using peer-to-peer transmission 428 | to receive a copy likewise does not require acceptance. However, 429 | nothing other than this License grants you permission to propagate or 430 | modify any covered work. These actions infringe copyright if you do 431 | not accept this License. Therefore, by modifying or propagating a 432 | covered work, you indicate your acceptance of this License to do so. 433 | 434 | 10. Automatic Licensing of Downstream Recipients. 435 | 436 | Each time you convey a covered work, the recipient automatically 437 | receives a license from the original licensors, to run, modify and 438 | propagate that work, subject to this License. You are not responsible 439 | for enforcing compliance by third parties with this License. 440 | 441 | An "entity transaction" is a transaction transferring control of an 442 | organization, or substantially all assets of one, or subdividing an 443 | organization, or merging organizations. If propagation of a covered 444 | work results from an entity transaction, each party to that 445 | transaction who receives a copy of the work also receives whatever 446 | licenses to the work the party's predecessor in interest had or could 447 | give under the previous paragraph, plus a right to possession of the 448 | Corresponding Source of the work from the predecessor in interest, if 449 | the predecessor has it or can get it with reasonable efforts. 450 | 451 | You may not impose any further restrictions on the exercise of the 452 | rights granted or affirmed under this License. For example, you may 453 | not impose a license fee, royalty, or other charge for exercise of 454 | rights granted under this License, and you may not initiate litigation 455 | (including a cross-claim or counterclaim in a lawsuit) alleging that 456 | any patent claim is infringed by making, using, selling, offering for 457 | sale, or importing the Program or any portion of it. 458 | 459 | 11. Patents. 460 | 461 | A "contributor" is a copyright holder who authorizes use under this 462 | License of the Program or a work on which the Program is based. The 463 | work thus licensed is called the contributor's "contributor version". 464 | 465 | A contributor's "essential patent claims" are all patent claims 466 | owned or controlled by the contributor, whether already acquired or 467 | hereafter acquired, that would be infringed by some manner, permitted 468 | by this License, of making, using, or selling its contributor version, 469 | but do not include claims that would be infringed only as a 470 | consequence of further modification of the contributor version. For 471 | purposes of this definition, "control" includes the right to grant 472 | patent sublicenses in a manner consistent with the requirements of 473 | this License. 474 | 475 | Each contributor grants you a non-exclusive, worldwide, royalty-free 476 | patent license under the contributor's essential patent claims, to 477 | make, use, sell, offer for sale, import and otherwise run, modify and 478 | propagate the contents of its contributor version. 479 | 480 | In the following three paragraphs, a "patent license" is any express 481 | agreement or commitment, however denominated, not to enforce a patent 482 | (such as an express permission to practice a patent or covenant not to 483 | sue for patent infringement). To "grant" such a patent license to a 484 | party means to make such an agreement or commitment not to enforce a 485 | patent against the party. 486 | 487 | If you convey a covered work, knowingly relying on a patent license, 488 | and the Corresponding Source of the work is not available for anyone 489 | to copy, free of charge and under the terms of this License, through a 490 | publicly available network server or other readily accessible means, 491 | then you must either (1) cause the Corresponding Source to be so 492 | available, or (2) arrange to deprive yourself of the benefit of the 493 | patent license for this particular work, or (3) arrange, in a manner 494 | consistent with the requirements of this License, to extend the patent 495 | license to downstream recipients. "Knowingly relying" means you have 496 | actual knowledge that, but for the patent license, your conveying the 497 | covered work in a country, or your recipient's use of the covered work 498 | in a country, would infringe one or more identifiable patents in that 499 | country that you have reason to believe are valid. 500 | 501 | If, pursuant to or in connection with a single transaction or 502 | arrangement, you convey, or propagate by procuring conveyance of, a 503 | covered work, and grant a patent license to some of the parties 504 | receiving the covered work authorizing them to use, propagate, modify 505 | or convey a specific copy of the covered work, then the patent license 506 | you grant is automatically extended to all recipients of the covered 507 | work and works based on it. 508 | 509 | A patent license is "discriminatory" if it does not include within 510 | the scope of its coverage, prohibits the exercise of, or is 511 | conditioned on the non-exercise of one or more of the rights that are 512 | specifically granted under this License. You may not convey a covered 513 | work if you are a party to an arrangement with a third party that is 514 | in the business of distributing software, under which you make payment 515 | to the third party based on the extent of your activity of conveying 516 | the work, and under which the third party grants, to any of the 517 | parties who would receive the covered work from you, a discriminatory 518 | patent license (a) in connection with copies of the covered work 519 | conveyed by you (or copies made from those copies), or (b) primarily 520 | for and in connection with specific products or compilations that 521 | contain the covered work, unless you entered into that arrangement, 522 | or that patent license was granted, prior to 28 March 2007. 523 | 524 | Nothing in this License shall be construed as excluding or limiting 525 | any implied license or other defenses to infringement that may 526 | otherwise be available to you under applicable patent law. 527 | 528 | 12. No Surrender of Others' Freedom. 529 | 530 | If conditions are imposed on you (whether by court order, agreement or 531 | otherwise) that contradict the conditions of this License, they do not 532 | excuse you from the conditions of this License. If you cannot convey a 533 | covered work so as to satisfy simultaneously your obligations under this 534 | License and any other pertinent obligations, then as a consequence you may 535 | not convey it at all. For example, if you agree to terms that obligate you 536 | to collect a royalty for further conveying from those to whom you convey 537 | the Program, the only way you could satisfy both those terms and this 538 | License would be to refrain entirely from conveying the Program. 539 | 540 | 13. Remote Network Interaction; Use with the GNU General Public License. 541 | 542 | Notwithstanding any other provision of this License, if you modify the 543 | Program, your modified version must prominently offer all users 544 | interacting with it remotely through a computer network (if your version 545 | supports such interaction) an opportunity to receive the Corresponding 546 | Source of your version by providing access to the Corresponding Source 547 | from a network server at no charge, through some standard or customary 548 | means of facilitating copying of software. This Corresponding Source 549 | shall include the Corresponding Source for any work covered by version 3 550 | of the GNU General Public License that is incorporated pursuant to the 551 | following paragraph. 552 | 553 | Notwithstanding any other provision of this License, you have 554 | permission to link or combine any covered work with a work licensed 555 | under version 3 of the GNU General Public License into a single 556 | combined work, and to convey the resulting work. The terms of this 557 | License will continue to apply to the part which is the covered work, 558 | but the work with which it is combined will remain governed by version 559 | 3 of the GNU General Public License. 560 | 561 | 14. Revised Versions of this License. 562 | 563 | The Free Software Foundation may publish revised and/or new versions of 564 | the GNU Affero General Public License from time to time. Such new versions 565 | will be similar in spirit to the present version, but may differ in detail to 566 | address new problems or concerns. 567 | 568 | Each version is given a distinguishing version number. If the 569 | Program specifies that a certain numbered version of the GNU Affero General 570 | Public License "or any later version" applies to it, you have the 571 | option of following the terms and conditions either of that numbered 572 | version or of any later version published by the Free Software 573 | Foundation. If the Program does not specify a version number of the 574 | GNU Affero General Public License, you may choose any version ever published 575 | by the Free Software Foundation. 576 | 577 | If the Program specifies that a proxy can decide which future 578 | versions of the GNU Affero General Public License can be used, that proxy's 579 | public statement of acceptance of a version permanently authorizes you 580 | to choose that version for the Program. 581 | 582 | Later license versions may give you additional or different 583 | permissions. However, no additional obligations are imposed on any 584 | author or copyright holder as a result of your choosing to follow a 585 | later version. 586 | 587 | 15. Disclaimer of Warranty. 588 | 589 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 590 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 591 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 592 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 593 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 594 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 595 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 596 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 597 | 598 | 16. Limitation of Liability. 599 | 600 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 601 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 602 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 603 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 604 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 605 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 606 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 607 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 608 | SUCH DAMAGES. 609 | 610 | 17. Interpretation of Sections 15 and 16. 611 | 612 | If the disclaimer of warranty and limitation of liability provided 613 | above cannot be given local legal effect according to their terms, 614 | reviewing courts shall apply local law that most closely approximates 615 | an absolute waiver of all civil liability in connection with the 616 | Program, unless a warranty or assumption of liability accompanies a 617 | copy of the Program in return for a fee. 618 | 619 | END OF TERMS AND CONDITIONS 620 | 621 | How to Apply These Terms to Your New Programs 622 | 623 | If you develop a new program, and you want it to be of the greatest 624 | possible use to the public, the best way to achieve this is to make it 625 | free software which everyone can redistribute and change under these terms. 626 | 627 | To do so, attach the following notices to the program. It is safest 628 | to attach them to the start of each source file to most effectively 629 | state the exclusion of warranty; and each file should have at least 630 | the "copyright" line and a pointer to where the full notice is found. 631 | 632 | 633 | Copyright (C) 634 | 635 | This program is free software: you can redistribute it and/or modify 636 | it under the terms of the GNU Affero General Public License as published 637 | by the Free Software Foundation, either version 3 of the License, or 638 | (at your option) any later version. 639 | 640 | This program is distributed in the hope that it will be useful, 641 | but WITHOUT ANY WARRANTY; without even the implied warranty of 642 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 643 | GNU Affero General Public License for more details. 644 | 645 | You should have received a copy of the GNU Affero General Public License 646 | along with this program. If not, see . 647 | 648 | Also add information on how to contact you by electronic and paper mail. 649 | 650 | If your software can interact with users remotely through a computer 651 | network, you should also make sure that it provides a way for users to 652 | get its source. For example, if your program is a web application, its 653 | interface could display a "Source" link that leads users to an archive 654 | of the code. There are many ways you could offer source, and different 655 | solutions will be better for different programs; see section 13 for the 656 | specific requirements. 657 | 658 | You should also get your employer (if you work as a programmer) or school, 659 | if any, to sign a "copyright disclaimer" for the program, if necessary. 660 | For more information on this, and how to apply and follow the GNU AGPL, see 661 | . 662 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # lala-companion 2 | 3 | 3D personified desktop assistants, tuned for you, powered by AI vision and voice. 4 | 5 | Early access in-development. 6 | 7 | ## Features 8 | 9 | - 3D VRM react-three-fiber avatars. 10 | - Always on microphone, voice to voice AI conversations. 11 | - Screen vision with GPT4-V. Self operating computer functions. 12 | - Install Lala Companion on Linux, Windows or Mac. 13 | - Resizable transparent overlay frame, always on-top AI interface for desktops. 14 | 15 | ## Join Lalaland 16 | 17 | [Discord](https://discord.gg/ypgqHYpEWw) | 18 | [X](https://twitter.com/lalaland_chat) 19 | 20 | ## Examples: 21 | 22 | ![image](https://github.com/lalaland-ai/lala-companion/assets/27584221/91a7a062-1d46-4bd7-90f2-f407a39a28d8) 23 | 24 | ![image](https://github.com/lalaland-ai/lala-companion/assets/27584221/a155d512-a953-4560-9290-1bc5b73992de) 25 | 26 | https://github.com/lalaland-ai/lala-companion/assets/27584221/bdc2e66b-4bbb-4cf1-9802-43f234ed0196 27 | 28 | ## Dev Local Setup 29 | 30 | Copy `.env.example` to `.env` and fill in the `OPENAI_API_KEY`. 31 | 32 | ```bash 33 | npm i 34 | 35 | NODE_OPTIONS="--no-experimental-strip-types" npm run start 36 | ``` 37 | 38 | ## Dev Notes 39 | 40 | This Electron React app consists of 2 main renderers or "views" that talk to eachother through IPC. 41 | The reason being, is its hard to build nice GUIs in an also fully transparent, click through, focus-less threejs 3D scene. 42 | 43 | As a rule, no buttons or 2D layers go in the 3D overlay. Only threejs 3D. Vanilla UIs go in "main". 44 | It ruins the vibe to mix. 45 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | lala-companion is an in-development, dynamically changing, early access app. It's "secure" as much as Electron is, but we do use alot of AI services which do interact with your data, so please be aware of that. 4 | Of course everything is mostly open source, except for some API calls, your free to inspect the code and see what is happening. 5 | AI touching your hard drives is a user option, highly warned about before allowed to turn on. We cannot guarantee much security if you choose to train AI with your desktop data to external providers. 6 | Local AI models running on your PC however, may be much more secure then using say: an OpenAI provider. We suggest doing that if you want max security and we will support a "local only" mode in our app. 7 | We don't have any weird backdoor user data farming, ad revenue, analytics stuff. Just some error reporting for devs to fix bugs, and general device metrics for QA. 8 | Open to audits if anyone wishes to do so. 9 | 10 | We shall prioritze "local" AI and local storage on your own machine, rather then cloud storage. - our motto, but hard to do sometimes if want next-gen AI features... so user options shall be given. 11 | 12 | ## Reporting a Vulnerability 13 | 14 | If you find something bad in the code or in data usage, please let us know in a Github Issue, Discord, X, or email. 15 | -------------------------------------------------------------------------------- /assets/animations/bored/female-pose-standing.glb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lalaland-ai/lala-companion/f9062aa726c2354050024b4cb7c29840c2517087/assets/animations/bored/female-pose-standing.glb -------------------------------------------------------------------------------- /assets/animations/bored/male-pose-standing.glb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lalaland-ai/lala-companion/f9062aa726c2354050024b4cb7c29840c2517087/assets/animations/bored/male-pose-standing.glb -------------------------------------------------------------------------------- /assets/animations/bored/rumba-dance.fbx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lalaland-ai/lala-companion/f9062aa726c2354050024b4cb7c29840c2517087/assets/animations/bored/rumba-dance.fbx -------------------------------------------------------------------------------- /assets/animations/bored/yawn.fbx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lalaland-ai/lala-companion/f9062aa726c2354050024b4cb7c29840c2517087/assets/animations/bored/yawn.fbx -------------------------------------------------------------------------------- /assets/animations/bored/yelling.fbx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lalaland-ai/lala-companion/f9062aa726c2354050024b4cb7c29840c2517087/assets/animations/bored/yelling.fbx -------------------------------------------------------------------------------- /assets/animations/bored/ymca.fbx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lalaland-ai/lala-companion/f9062aa726c2354050024b4cb7c29840c2517087/assets/animations/bored/ymca.fbx -------------------------------------------------------------------------------- /assets/animations/greet/greet-1.fbx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lalaland-ai/lala-companion/f9062aa726c2354050024b4cb7c29840c2517087/assets/animations/greet/greet-1.fbx -------------------------------------------------------------------------------- /assets/animations/idle/idle-1.fbx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lalaland-ai/lala-companion/f9062aa726c2354050024b4cb7c29840c2517087/assets/animations/idle/idle-1.fbx -------------------------------------------------------------------------------- /assets/animations/idle/idle-2.fbx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lalaland-ai/lala-companion/f9062aa726c2354050024b4cb7c29840c2517087/assets/animations/idle/idle-2.fbx -------------------------------------------------------------------------------- /assets/animations/idle/idle-3.fbx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lalaland-ai/lala-companion/f9062aa726c2354050024b4cb7c29840c2517087/assets/animations/idle/idle-3.fbx -------------------------------------------------------------------------------- /assets/animations/idle/idle-4.fbx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lalaland-ai/lala-companion/f9062aa726c2354050024b4cb7c29840c2517087/assets/animations/idle/idle-4.fbx -------------------------------------------------------------------------------- /assets/animations/talk/talk-1.fbx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lalaland-ai/lala-companion/f9062aa726c2354050024b4cb7c29840c2517087/assets/animations/talk/talk-1.fbx -------------------------------------------------------------------------------- /assets/animations/talk/talk-2.fbx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lalaland-ai/lala-companion/f9062aa726c2354050024b4cb7c29840c2517087/assets/animations/talk/talk-2.fbx -------------------------------------------------------------------------------- /assets/animations/talk/talk-3.fbx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lalaland-ai/lala-companion/f9062aa726c2354050024b4cb7c29840c2517087/assets/animations/talk/talk-3.fbx -------------------------------------------------------------------------------- /assets/animations/walk/walk-1.fbx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lalaland-ai/lala-companion/f9062aa726c2354050024b4cb7c29840c2517087/assets/animations/walk/walk-1.fbx -------------------------------------------------------------------------------- /assets/animations/walk/walk-2.fbx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lalaland-ai/lala-companion/f9062aa726c2354050024b4cb7c29840c2517087/assets/animations/walk/walk-2.fbx -------------------------------------------------------------------------------- /assets/images/lalaland.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lalaland-ai/lala-companion/f9062aa726c2354050024b4cb7c29840c2517087/assets/images/lalaland.png -------------------------------------------------------------------------------- /assets/vrms/lala.vrm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lalaland-ai/lala-companion/f9062aa726c2354050024b4cb7c29840c2517087/assets/vrms/lala.vrm -------------------------------------------------------------------------------- /forge.config.ts: -------------------------------------------------------------------------------- 1 | import type { ForgeConfig } from "@electron-forge/shared-types"; 2 | import { MakerSquirrel } from "@electron-forge/maker-squirrel"; 3 | import { MakerZIP } from "@electron-forge/maker-zip"; 4 | import { MakerDeb } from "@electron-forge/maker-deb"; 5 | import { MakerRpm } from "@electron-forge/maker-rpm"; 6 | import { AutoUnpackNativesPlugin } from "@electron-forge/plugin-auto-unpack-natives"; 7 | import { WebpackPlugin } from "@electron-forge/plugin-webpack"; 8 | import { FusesPlugin } from "@electron-forge/plugin-fuses"; 9 | import { FuseV1Options, FuseVersion } from "@electron/fuses"; 10 | import dotenv from "dotenv"; 11 | 12 | import { mainConfig } from "./webpack.main.config"; 13 | import { rendererConfig } from "./webpack.renderer.config"; 14 | 15 | dotenv.config(); 16 | 17 | const config: ForgeConfig = { 18 | packagerConfig: { 19 | asar: true, 20 | }, 21 | rebuildConfig: {}, 22 | makers: [ 23 | new MakerSquirrel({}), 24 | new MakerZIP({}, ["darwin"]), 25 | new MakerRpm({}), 26 | new MakerDeb({}), 27 | ], 28 | 29 | plugins: [ 30 | new AutoUnpackNativesPlugin({}), 31 | new WebpackPlugin({ 32 | mainConfig, 33 | renderer: { 34 | config: rendererConfig, 35 | entryPoints: [ 36 | { 37 | html: "./src/index.html", 38 | js: "./src/renderer.ts", 39 | name: "main_window", 40 | preload: { 41 | js: "./src/preload.ts", 42 | }, 43 | }, 44 | { 45 | html: "./src//overlay/index.html", 46 | js: "./src/overlay/renderer.ts", 47 | name: "overlay_window", 48 | preload: { 49 | js: "./src/preload.ts", 50 | }, 51 | }, 52 | ], 53 | }, 54 | }), 55 | // Fuses are used to enable/disable various Electron functionality 56 | // at package time, before code signing the application 57 | new FusesPlugin({ 58 | version: FuseVersion.V1, 59 | [FuseV1Options.RunAsNode]: false, 60 | [FuseV1Options.EnableCookieEncryption]: true, 61 | [FuseV1Options.EnableNodeOptionsEnvironmentVariable]: false, 62 | [FuseV1Options.EnableNodeCliInspectArguments]: false, 63 | [FuseV1Options.EnableEmbeddedAsarIntegrityValidation]: true, 64 | [FuseV1Options.OnlyLoadAppFromAsar]: true, 65 | }), 66 | ], 67 | publishers: [ 68 | { 69 | name: "@electron-forge/publisher-github", 70 | config: { 71 | repository: { 72 | owner: "lalaland-ai", 73 | name: "lala-companion", 74 | }, 75 | prerelease: true, 76 | }, 77 | }, 78 | ], 79 | }; 80 | 81 | export default config; 82 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "lala-companion", 3 | "productName": "lala-companion", 4 | "version": "0.0.15", 5 | "description": "3D personified desktop assistants, tuned for you, powered by AI vision and voice.", 6 | "main": ".webpack/main", 7 | "scripts": { 8 | "start": "electron-forge start", 9 | "package": "electron-forge package", 10 | "make": "electron-forge make", 11 | "publish": "electron-forge publish", 12 | "lint": "eslint --ext .ts,.tsx ." 13 | }, 14 | "keywords": [], 15 | "author": { 16 | "name": "cjft", 17 | "email": "cjft@trimboli.io" 18 | }, 19 | "repository": { 20 | "type": "git", 21 | "url": "https://github.com/lalaland-ai/lala-companion.git" 22 | }, 23 | "license": "AGPL-3.0", 24 | "devDependencies": { 25 | "@electron-forge/cli": "^7.8.0", 26 | "@electron-forge/maker-deb": "^7.8.0", 27 | "@electron-forge/maker-rpm": "^7.8.0", 28 | "@electron-forge/maker-squirrel": "^7.8.0", 29 | "@electron-forge/maker-zip": "^7.8.0", 30 | "@electron-forge/plugin-auto-unpack-natives": "^7.8.0", 31 | "@electron-forge/plugin-fuses": "^7.8.0", 32 | "@electron-forge/plugin-webpack": "^7.8.0", 33 | "@electron-forge/publisher-github": "^7.8.0", 34 | "@electron/fuses": "^1.8.0", 35 | "@types/hark": "^1.2.5", 36 | "@types/react-dom": "^19.1.1", 37 | "@typescript-eslint/eslint-plugin": "^8.29.0", 38 | "@typescript-eslint/parser": "^8.29.0", 39 | "@vercel/webpack-asset-relocator-loader": "1.7.3", 40 | "copy-webpack-plugin": "^13.0.0", 41 | "css-loader": "^7.1.2", 42 | "electron": "35.1.3", 43 | "eslint": "^9.23.0", 44 | "eslint-plugin-import": "^2.31.0", 45 | "fork-ts-checker-webpack-plugin": "^9.1.0", 46 | "node-loader": "^2.1.0", 47 | "style-loader": "^4.0.0", 48 | "ts-loader": "^9.5.2", 49 | "ts-node": "^10.9.2", 50 | "typescript": "^5.8.2" 51 | }, 52 | "dependencies": { 53 | "@ai-sdk/openai": "^1.3.6", 54 | "@ai-sdk/react": "^1.2.5", 55 | "@emotion/react": "^11.14.0", 56 | "@emotion/styled": "^11.14.0", 57 | "@mui/icons-material": "^7.0.1", 58 | "@mui/material": "^7.0.1", 59 | "@pixiv/three-vrm": "^3.3.6", 60 | "@react-three/drei": "^10.0.5", 61 | "@react-three/fiber": "^9.1.1", 62 | "@react-three/rapier": "^2.0.0", 63 | "ai": "^4.2.11", 64 | "dotenv": "^16.4.7", 65 | "electron-squirrel-startup": "^1.0.1", 66 | "hark": "^1.2.3", 67 | "node-fetch": "^3.3.2", 68 | "react": "^19.1.0", 69 | "react-dom": "^19.1.0", 70 | "three": "^0.175.0", 71 | "update-electron-app": "^3.1.1", 72 | "wavesurfer.js": "^7.9.4" 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /src/App.tsx: -------------------------------------------------------------------------------- 1 | import { 2 | Box, 3 | Button, 4 | Container, 5 | FormControlLabel, 6 | IconButton, 7 | InputBase, 8 | Paper, 9 | Stack, 10 | Switch, 11 | ThemeProvider, 12 | Typography, 13 | } from "@mui/material"; 14 | import React, { FormEvent, useCallback, useState } from "react"; 15 | import { theme } from "./theme"; 16 | import CssBaseline from "@mui/material/CssBaseline"; 17 | import TabUnselectedIcon from "@mui/icons-material/TabUnselected"; 18 | import WebAssetOffIcon from "@mui/icons-material/WebAssetOff"; 19 | import SendIcon from "@mui/icons-material/Send"; 20 | 21 | const App = () => { 22 | const [isOverlayOpen, setIsOverlayOpen] = useState(false); 23 | const [isOverlayFrameActive, setIsOverlayFrameActive] = useState(false); 24 | const [prompt, setPrompt] = useState(""); 25 | const [isHotMicActive, setIsHotMicActive] = useState(false); 26 | 27 | const onOpenOverlay = useCallback(() => { 28 | (window as any).electronAPI.openOverlay(); 29 | setIsOverlayOpen(true); 30 | }, []); 31 | 32 | const onCloseOverlay = useCallback(() => { 33 | (window as any).electronAPI.closeOverlay(); 34 | setIsOverlayOpen(false); 35 | }, []); 36 | 37 | const onPromptSubmit = useCallback( 38 | (e: React.FormEvent) => { 39 | e.preventDefault(); 40 | console.log("prompt", prompt); 41 | (window as any).electronAPI.sendPrompt(prompt); 42 | setPrompt(""); 43 | }, 44 | [prompt] 45 | ); 46 | 47 | const onToggleHotMic = useCallback(() => { 48 | setIsHotMicActive(!isHotMicActive); 49 | (window as any).electronAPI.setHotMic(!isHotMicActive); 50 | }, [isHotMicActive]); 51 | 52 | const onPromptChange = useCallback( 53 | (e: React.ChangeEvent) => { 54 | setPrompt(e.target.value); 55 | (window as any).electronAPI.setPrompt(e.target.value); 56 | }, 57 | [] 58 | ); 59 | 60 | return ( 61 | 62 | 63 | Lala 71 | 72 | 73 | 74 | Lala Companion 75 | 76 | 77 | 78 | 3D personified desktop assistants, tuned for you, powered by AI vision 79 | and voice 80 | 81 | 82 | 83 | 90 | 91 | {isOverlayOpen && ( 92 | <> 93 | 109 | 110 | 119 | 125 | 129 | onPromptSubmit({ 130 | preventDefault: () => {}, 131 | } as FormEvent) 132 | } 133 | > 134 | 135 | 136 | 137 | 138 | 141 | } 142 | label="Always on microphone" 143 | /> 144 | 145 | )} 146 | 147 | 148 | ); 149 | }; 150 | 151 | const AppLayout = () => { 152 | return ( 153 | 154 | 155 | 156 | 157 | 158 | ); 159 | }; 160 | 161 | export default AppLayout; 162 | -------------------------------------------------------------------------------- /src/Scene.tsx: -------------------------------------------------------------------------------- 1 | import { VRM } from "@pixiv/three-vrm"; 2 | import { OrbitControls } from "@react-three/drei"; 3 | import { Canvas } from "@react-three/fiber"; 4 | import { RapierRigidBody } from "@react-three/rapier"; 5 | import React, { useRef, useEffect, RefObject } from "react"; 6 | import { Mesh } from "three"; 7 | import { animations } from "./constants/animations"; 8 | import VrmCompanion from "./components/VRMCompanion"; 9 | 10 | interface SceneProps { 11 | virtualText: string; 12 | voiceUrl: string; 13 | audioRef?: RefObject; 14 | onSpeakStart?: () => void; 15 | onSpeakEnd?: () => void; 16 | } 17 | 18 | const Scene = ({ 19 | virtualText, 20 | voiceUrl, 21 | onSpeakStart, 22 | onSpeakEnd, 23 | }: SceneProps) => { 24 | const vrmRef = useRef(null); 25 | const vrmMeshRef = useRef(null); 26 | const vrmPhysicsRef = useRef(null); 27 | 28 | useEffect(() => { 29 | if (virtualText) { 30 | (vrmRef as any)?.current?.setText?.(virtualText); 31 | } 32 | }, [virtualText]); 33 | 34 | useEffect(() => { 35 | const speak = async () => { 36 | if (voiceUrl) { 37 | onSpeakStart?.(); 38 | await (vrmRef as any)?.current?.talk?.(voiceUrl); 39 | onSpeakEnd?.(); 40 | } 41 | }; 42 | speak(); 43 | }, [voiceUrl]); 44 | 45 | return ( 46 | <> 47 | 54 | 60 | 61 | 62 | {/* left */} 63 | 64 | 65 | {/* right */} 66 | 67 | 68 | 79 | 80 | 81 | ); 82 | }; 83 | 84 | export default Scene; 85 | -------------------------------------------------------------------------------- /src/components/VRMCompanion.tsx: -------------------------------------------------------------------------------- 1 | import React, { 2 | RefObject, 3 | Suspense, 4 | forwardRef, 5 | useCallback, 6 | useEffect, 7 | useImperativeHandle, 8 | useMemo, 9 | useRef, 10 | useState, 11 | } from "react"; 12 | import { useFrame } from "@react-three/fiber"; 13 | import { 14 | GLTF, 15 | GLTFLoader, 16 | GLTFParser, 17 | } from "three/examples/jsm/loaders/GLTFLoader"; 18 | import { 19 | VRM, 20 | VRMUtils, 21 | VRMLoaderPlugin, 22 | VRMSpringBoneColliderShapeCapsule, 23 | VRMSpringBoneColliderShapeSphere, 24 | VRMExpressionPresetName, 25 | } from "@pixiv/three-vrm"; 26 | import { 27 | AnimationAction, 28 | AnimationClip, 29 | AnimationMixer, 30 | Euler, 31 | LoopOnce, 32 | Mesh, 33 | NumberKeyframeTrack, 34 | Vector3, 35 | } from "three"; 36 | import { loadMixamoAnimation } from "../helpers/loadMixamoAnimation"; 37 | import { RapierRigidBody, RigidBody } from "@react-three/rapier"; 38 | import { Text } from "@react-three/drei"; 39 | 40 | export const emotions = { 41 | happy: VRMExpressionPresetName.Happy, 42 | sad: VRMExpressionPresetName.Sad, 43 | angry: VRMExpressionPresetName.Angry, 44 | relaxed: VRMExpressionPresetName.Relaxed, 45 | surprised: VRMExpressionPresetName.Surprised, 46 | neutral: VRMExpressionPresetName.Neutral, 47 | }; 48 | 49 | interface VrmAvatarProps { 50 | meshRef?: RefObject; 51 | physicsRef?: RefObject; 52 | vrmUrl: string; 53 | animations: Record<"greet" | "idle" | "talk" | "bored" | "walk", string[]>; 54 | scale: number[]; 55 | rotation?: number[]; 56 | position?: number[]; 57 | physics?: boolean; 58 | isStaticPosition?: boolean; 59 | gltfLoaded?: (gltf: GLTF) => void; 60 | } 61 | 62 | const VrmCompanion = forwardRef( 63 | ( 64 | { 65 | meshRef, 66 | physicsRef, 67 | vrmUrl, 68 | animations, 69 | scale, 70 | rotation, 71 | position, 72 | physics, 73 | isStaticPosition, 74 | gltfLoaded, 75 | }: VrmAvatarProps, 76 | ref 77 | ) => { 78 | const [gltf, setGltf] = useState(null); 79 | const [animationMixer, setAnimationMixer] = useState( 80 | null 81 | ); 82 | const [prevVrmUrl, setPrevVrmUrl] = useState(null); 83 | const [currentText, setCurrentText] = useState(""); 84 | 85 | const [targetPosition, setTargetPosition] = useState(position); 86 | const [targetLookAt, setTargetLookAt] = useState(null); 87 | const [animationCache, setAnimationCache] = useState< 88 | Record 89 | >({}); 90 | const [audioContext, setAudioContext] = useState(null); 91 | const [analyser, setAnalyser] = useState(null); 92 | const [audio, setAudio] = useState(null); 93 | 94 | const loader = useMemo(() => { 95 | return new GLTFLoader().register( 96 | (parser: GLTFParser) => 97 | new VRMLoaderPlugin(parser, { 98 | autoUpdateHumanBones: true, 99 | }) 100 | ); 101 | }, []); 102 | 103 | const rigidBodyRef = useRef(null); 104 | const gltfRef = useRef(null); 105 | const vrmRef = useRef(null); 106 | const virtualTextRef = useRef(null); 107 | 108 | // bind refs to props for external access 109 | useEffect(() => { 110 | if (meshRef) { 111 | meshRef.current = gltfRef.current; 112 | } 113 | if (physicsRef) { 114 | physicsRef.current = rigidBodyRef.current; 115 | } 116 | }, [meshRef, physicsRef]); 117 | 118 | useFrame(({ camera }, delta) => { 119 | if (animationMixer?.update) { 120 | animationMixer.update(delta); 121 | } 122 | if (vrmRef?.current?.update) { 123 | vrmRef.current.update(delta); 124 | } 125 | 126 | if (virtualTextRef.current && gltfRef.current) { 127 | const avatarPosition = new Vector3().setFromMatrixPosition( 128 | gltfRef.current.matrixWorld 129 | ); 130 | virtualTextRef.current.position.copy(avatarPosition); 131 | virtualTextRef.current.position.y += 1.5; 132 | virtualTextRef.current.lookAt(camera.position); 133 | } 134 | 135 | if (gltfRef?.current?.matrixWorld && !isStaticPosition) { 136 | const currentPosition = new Vector3().setFromMatrixPosition( 137 | gltfRef.current.matrixWorld 138 | ); 139 | 140 | const distance = currentPosition.distanceTo( 141 | new Vector3(...targetPosition) 142 | ); 143 | 144 | if (gltfRef.current && distance > 0.1) { 145 | gltfRef.current.position.lerp(new Vector3(...targetPosition), 0.01); 146 | } 147 | } 148 | if (gltfRef?.current?.lookAt && targetLookAt && !isStaticPosition) { 149 | gltfRef.current.lookAt(new Vector3(...targetLookAt)); 150 | gltfRef.current.rotateY(Math.PI); 151 | } 152 | }); 153 | 154 | const getRandomAnimation = useCallback( 155 | (type: string) => { 156 | const randomAnim = (animations as any)?.[type]?.[ 157 | Math.floor(Math.random() * (animations as any)?.[type]?.length) 158 | ]; 159 | 160 | return randomAnim; 161 | }, 162 | [animations] 163 | ); 164 | 165 | const playAnimation = useCallback( 166 | async (type: string) => { 167 | animationCache[type][0].reset().setLoop(LoopOnce, 1).play(); 168 | }, 169 | [animationCache] 170 | ); 171 | 172 | const moveMouth = useCallback( 173 | async (audioUrl: string) => { 174 | try { 175 | const audioResp = await fetch(audioUrl); 176 | const audioBuffer = await audioResp.arrayBuffer(); 177 | const source = audioContext?.createBufferSource(); 178 | const audio = await audioContext?.decodeAudioData(audioBuffer); 179 | source.buffer = audio; 180 | source?.connect(analyser); 181 | source.start(0); 182 | 183 | const dataArray = new Uint8Array(analyser.frequencyBinCount); 184 | 185 | const updateMouth = () => { 186 | requestAnimationFrame(updateMouth); 187 | 188 | analyser.getByteFrequencyData(dataArray); 189 | 190 | const volume = dataArray.reduce((a, b) => a + b) / dataArray.length; 191 | const normalizationFactor = 50; 192 | const normalizedVolume = Math.min(1, volume / normalizationFactor); 193 | 194 | // Set the weight of the 'Aa' blend shape based on the volume 195 | vrmRef.current.expressionManager.setValue("aa", normalizedVolume); 196 | vrmRef.current.expressionManager.update(); 197 | }; 198 | 199 | updateMouth(); 200 | } catch (error) { 201 | console.error(error); 202 | } 203 | }, 204 | [audioContext, analyser] 205 | ); 206 | 207 | const setupAudioAnalyser = useCallback(async () => { 208 | const audioContext = new (window.AudioContext || 209 | (window as any).webkitAudioContext)(); 210 | setAudioContext(audioContext); 211 | 212 | const analyser = audioContext?.createAnalyser(); 213 | setAnalyser(analyser); 214 | }, []); 215 | 216 | const setupAudioPlayer = useCallback(async () => { 217 | const audio = new Audio(); 218 | setAudio(audio); 219 | }, []); 220 | 221 | const setupAnimations = useCallback(async () => { 222 | return new Promise(async (resolve) => { 223 | const mixer = new AnimationMixer(vrmRef.current.scene); 224 | mixer.timeScale = 1.0; 225 | setAnimationMixer(mixer); 226 | 227 | // load walk animation 228 | const randomWalk = getRandomAnimation("walk"); 229 | const walkClip = await loadMixamoAnimation(randomWalk, vrmRef.current); 230 | const walkAction = mixer.clipAction(walkClip); 231 | 232 | // // load idle animation 233 | const randomIdle = getRandomAnimation("idle"); 234 | const idleClip = await loadMixamoAnimation(randomIdle, vrmRef.current); 235 | const idleAction = mixer.clipAction(idleClip); 236 | 237 | setAnimationCache((prev) => ({ 238 | ...prev, 239 | walk: [...(prev?.walk || []), walkAction], 240 | idle: [...(prev?.idle || []), idleAction], 241 | })); 242 | 243 | idleAction.play(); 244 | 245 | // blink loop 246 | const blinkTrack = 247 | vrmRef.current.expressionManager.getExpressionTrackName("blink"); 248 | const blinkKeys = new NumberKeyframeTrack( 249 | blinkTrack as string, 250 | [0.0, 0.2, 0.4, 6.0], // times 251 | [0.0, 1.0, 0.0, 0.0] // values 252 | ); 253 | const blinkClip = new AnimationClip( 254 | blinkTrack as string, 255 | 6.8, // duration 256 | [blinkKeys] 257 | ); 258 | const action = mixer.clipAction(blinkClip); 259 | action.play(); 260 | resolve(mixer); 261 | }); 262 | }, [getRandomAnimation]); 263 | 264 | // load vrm and play greet animation 265 | useEffect(() => { 266 | if ((!gltf && vrmUrl) || prevVrmUrl !== vrmUrl) { 267 | loader.loadAsync(vrmUrl).then(async (gltf: GLTF) => { 268 | setPrevVrmUrl(vrmUrl); 269 | const vrm = gltf.userData.vrm as VRM; 270 | VRMUtils.combineSkeletons(vrm.scene); 271 | VRMUtils.removeUnnecessaryVertices(vrm.scene); 272 | 273 | vrm.scene.traverse((obj) => { 274 | obj.frustumCulled = false; 275 | }); 276 | 277 | const vrmScale = scale[0]; 278 | 279 | if (scale[0]) { 280 | vrm.scene.scale.setScalar(scale[0]); 281 | 282 | // scale joints 283 | for (const joint of vrm.springBoneManager.joints) { 284 | joint.settings.stiffness *= vrmScale; 285 | joint.settings.hitRadius *= vrmScale; 286 | } 287 | 288 | // scale colliders 289 | for (const collider of vrm.springBoneManager.colliders) { 290 | const shape = collider.shape; 291 | if (shape instanceof VRMSpringBoneColliderShapeCapsule) { 292 | shape.radius *= vrmScale; 293 | shape.tail.multiplyScalar(vrmScale); 294 | } else if (shape instanceof VRMSpringBoneColliderShapeSphere) { 295 | shape.radius *= vrmScale; 296 | } 297 | } 298 | } 299 | 300 | setGltf(gltf); 301 | 302 | vrmRef.current = vrm; 303 | 304 | gltfLoaded?.(gltf); 305 | 306 | await setupAnimations(); 307 | await setupAudioAnalyser(); 308 | await setupAudioPlayer(); 309 | }); 310 | } 311 | }, [ 312 | vrmUrl, 313 | scale, 314 | gltf, 315 | loader, 316 | prevVrmUrl, 317 | getRandomAnimation, 318 | gltfLoaded, 319 | playAnimation, 320 | setupAnimations, 321 | setupAudioAnalyser, 322 | setupAudioPlayer, 323 | ]); 324 | 325 | useImperativeHandle(ref, () => ({ 326 | setText: (text: string) => { 327 | setCurrentText(text); 328 | }, 329 | moveTo: async (position: number[]) => { 330 | await playAnimation("walk"); 331 | setTargetPosition(position); 332 | }, 333 | lookAt: (position: number[]) => { 334 | setTargetLookAt(position); 335 | }, 336 | getPosition: () => { 337 | return new Vector3().setFromMatrixPosition(gltfRef.current.matrixWorld); 338 | }, 339 | talk: async (audioUrl: string, targetLookAt?: number[]) => 340 | new Promise(async (resolve) => { 341 | const randomTalk = getRandomAnimation("talk"); 342 | const talkClip = await loadMixamoAnimation( 343 | randomTalk, 344 | vrmRef.current 345 | ); 346 | const talkAction = animationMixer?.clipAction(talkClip); 347 | talkAction?.reset().setLoop(LoopOnce, 1).fadeIn(1).play(); 348 | 349 | setTimeout(() => { 350 | talkAction?.fadeOut(1); 351 | }, (talkClip.duration - 1) * 1000); 352 | 353 | await moveMouth(audioUrl); 354 | 355 | if (targetLookAt) { 356 | setTargetLookAt(targetLookAt); 357 | } 358 | 359 | audio.src = audioUrl; 360 | audio.play(); 361 | 362 | audio.addEventListener("ended", () => { 363 | if (talkAction.isRunning()) { 364 | talkAction.fadeOut(1); 365 | } 366 | resolve("ended"); 367 | }); 368 | }), 369 | playEmotion: async (emotion: string) => { 370 | // facial emotion 371 | const expressionManager = vrmRef.current?.expressionManager; 372 | 373 | if (expressionManager) { 374 | const transitionSpeed = 0.1; // Adjust this value to change the speed of the transition 375 | const updateFrequency = 75; // Adjust this value to change the frequency of the updates 376 | 377 | // Transition into the emotion 378 | const transitionInInterval = setInterval(() => { 379 | const currentValue = expressionManager.getValue(emotion); 380 | if (currentValue >= 1) { 381 | clearInterval(transitionInInterval); 382 | } else { 383 | expressionManager.setValue( 384 | emotion, 385 | currentValue + transitionSpeed 386 | ); 387 | expressionManager.update(); 388 | } 389 | }, updateFrequency); 390 | 391 | // Wait for 2-3 seconds, then transition out of the emotion 392 | setTimeout(() => { 393 | const transitionOutInterval = setInterval(() => { 394 | const currentValue = expressionManager.getValue(emotion); 395 | if (currentValue <= 0) { 396 | clearInterval(transitionOutInterval); 397 | } else { 398 | expressionManager.setValue( 399 | emotion, 400 | currentValue - transitionSpeed 401 | ); 402 | expressionManager.update(); 403 | } 404 | }, updateFrequency); 405 | }, 2000 + Math.random() * 1000); // Wait for a random time between 2 and 3 seconds 406 | } 407 | 408 | // body emotion 409 | if (emotion === "happy" || emotion === "angry" || emotion === "sad") { 410 | const randomEmotion = getRandomAnimation(emotion); 411 | const emotionClip = await loadMixamoAnimation( 412 | randomEmotion, 413 | vrmRef.current 414 | ); 415 | const emotionAction = animationMixer?.clipAction(emotionClip); 416 | emotionAction?.reset().setLoop(LoopOnce, 1).fadeIn(1).play(); 417 | 418 | setTimeout(() => { 419 | emotionAction?.fadeOut(1); 420 | }, (emotionClip.duration - 1) * 1000); 421 | } 422 | }, 423 | })); 424 | 425 | return ( 426 | <> 427 | {gltf?.scene && ( 428 | 429 | {physics ? ( 430 | 431 | 441 | {currentText} 442 | 443 | 456 | 463 | 464 | 465 | ) : ( 466 | 467 | 477 | {currentText} 478 | 479 | 488 | 489 | )} 490 | 491 | )} 492 | 493 | ); 494 | } 495 | ); 496 | 497 | export default VrmCompanion; 498 | -------------------------------------------------------------------------------- /src/constants/animations.ts: -------------------------------------------------------------------------------- 1 | export const animations = { 2 | idle: [ 3 | "./assets/animations/idle/idle-1.fbx", 4 | "./assets/animations/idle/idle-2.fbx", 5 | "./assets/animations/idle/idle-3.fbx", 6 | "./assets/animations/idle/idle-4.fbx", 7 | ], 8 | greet: ["./assets/animations/greet/greet-1.fbx"], 9 | talk: [ 10 | "./assets/animations/talk/talk-1.fbx", 11 | "./assets/animations/talk/talk-2.fbx", 12 | "./assets/animations/talk/talk-3.fbx", 13 | ], 14 | bored: [ 15 | "./assets/animations/bored/female-pose-standing.fbx", 16 | "./assets/animations/bored/male-pose-standing.fbx", 17 | "./assets/animations/bored/rumba-dance.fbx", 18 | "./assets/animations/bored/yawn.fbx", 19 | "./assets/animations/bored/yelling.fbx", 20 | "./assets/animations/bored/ymca.fbx", 21 | ], 22 | walk: [ 23 | "./assets/animations/walk/walk-1.fbx", 24 | "./assets/animations/walk/walk-2.fbx", 25 | ], 26 | }; 27 | -------------------------------------------------------------------------------- /src/helpers/loadMixamoAnimation.js: -------------------------------------------------------------------------------- 1 | import * as THREE from "three"; 2 | import { FBXLoader } from "three/examples/jsm/loaders/FBXLoader.js"; 3 | import { mixamoVRMRigMap } from "./mixamoVRMRigMap"; 4 | 5 | /** 6 | * Load Mixamo animation, convert for three-vrm use, and return it. 7 | * 8 | * @param {string} url A url of mixamo animation data 9 | * @param {VRM} vrm A target VRM 10 | * @returns {Promise} The converted AnimationClip 11 | */ 12 | export function loadMixamoAnimation(url, vrm) { 13 | const loader = new FBXLoader(); // A loader which loads FBX 14 | return loader.loadAsync(url).then((asset) => { 15 | const clip = THREE.AnimationClip.findByName(asset.animations, "mixamo.com"); // extract the AnimationClip 16 | 17 | const tracks = []; // KeyframeTracks compatible with VRM will be added here 18 | 19 | const restRotationInverse = new THREE.Quaternion(); 20 | const parentRestWorldRotation = new THREE.Quaternion(); 21 | const _quatA = new THREE.Quaternion(); 22 | const _vec3 = new THREE.Vector3(); 23 | 24 | // Adjust with reference to hips height. 25 | const motionHipsHeight = asset.getObjectByName("mixamorigHips").position.y; 26 | const vrmHipsY = vrm.humanoid 27 | ?.getNormalizedBoneNode("hips") 28 | .getWorldPosition(_vec3).y; 29 | const vrmRootY = vrm.scene.getWorldPosition(_vec3).y; 30 | const vrmHipsHeight = Math.abs(vrmHipsY - vrmRootY); 31 | const hipsPositionScale = vrmHipsHeight / motionHipsHeight; 32 | 33 | clip.tracks.forEach((track) => { 34 | // Convert each tracks for VRM use, and push to `tracks` 35 | const trackSplitted = track.name.split("."); 36 | const mixamoRigName = trackSplitted[0]; 37 | const vrmBoneName = mixamoVRMRigMap[mixamoRigName]; 38 | const vrmNodeName = 39 | vrm.humanoid?.getNormalizedBoneNode(vrmBoneName)?.name; 40 | const mixamoRigNode = asset.getObjectByName(mixamoRigName); 41 | 42 | if (vrmNodeName != null) { 43 | const propertyName = trackSplitted[1]; 44 | 45 | // Store rotations of rest-pose. 46 | mixamoRigNode.getWorldQuaternion(restRotationInverse).invert(); 47 | mixamoRigNode.parent.getWorldQuaternion(parentRestWorldRotation); 48 | 49 | if (track instanceof THREE.QuaternionKeyframeTrack) { 50 | // Retarget rotation of mixamoRig to NormalizedBone. 51 | for (let i = 0; i < track.values.length; i += 4) { 52 | const flatQuaternion = track.values.slice(i, i + 4); 53 | 54 | _quatA.fromArray(flatQuaternion); 55 | 56 | // 親のレスト時ワールド回転 * トラックの回転 * レスト時ワールド回転の逆 57 | _quatA 58 | .premultiply(parentRestWorldRotation) 59 | .multiply(restRotationInverse); 60 | 61 | _quatA.toArray(flatQuaternion); 62 | 63 | flatQuaternion.forEach((v, index) => { 64 | track.values[index + i] = v; 65 | }); 66 | } 67 | 68 | tracks.push( 69 | new THREE.QuaternionKeyframeTrack( 70 | `${vrmNodeName}.${propertyName}`, 71 | track.times, 72 | track.values.map((v, i) => 73 | vrm.meta?.metaVersion === "0" && i % 2 === 0 ? -v : v 74 | ) 75 | ) 76 | ); 77 | } else if (track instanceof THREE.VectorKeyframeTrack) { 78 | const value = track.values.map( 79 | (v, i) => 80 | (vrm.meta?.metaVersion === "0" && i % 3 !== 1 ? -v : v) * 81 | hipsPositionScale 82 | ); 83 | tracks.push( 84 | new THREE.VectorKeyframeTrack( 85 | `${vrmNodeName}.${propertyName}`, 86 | track.times, 87 | value 88 | ) 89 | ); 90 | } 91 | } 92 | }); 93 | 94 | return new THREE.AnimationClip("vrmAnimation", clip.duration, tracks); 95 | }); 96 | } 97 | -------------------------------------------------------------------------------- /src/helpers/mixamoVRMRigMap.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * A map from Mixamo rig name to VRM Humanoid bone name 3 | */ 4 | export const mixamoVRMRigMap = { 5 | mixamorigHips: "hips", 6 | mixamorigSpine: "spine", 7 | mixamorigSpine1: "chest", 8 | mixamorigSpine2: "upperChest", 9 | mixamorigNeck: "neck", 10 | mixamorigHead: "head", 11 | mixamorigLeftShoulder: "leftShoulder", 12 | mixamorigLeftArm: "leftUpperArm", 13 | mixamorigLeftForeArm: "leftLowerArm", 14 | mixamorigLeftHand: "leftHand", 15 | mixamorigLeftHandThumb1: "leftThumbMetacarpal", 16 | mixamorigLeftHandThumb2: "leftThumbProximal", 17 | mixamorigLeftHandThumb3: "leftThumbDistal", 18 | mixamorigLeftHandIndex1: "leftIndexProximal", 19 | mixamorigLeftHandIndex2: "leftIndexIntermediate", 20 | mixamorigLeftHandIndex3: "leftIndexDistal", 21 | mixamorigLeftHandMiddle1: "leftMiddleProximal", 22 | mixamorigLeftHandMiddle2: "leftMiddleIntermediate", 23 | mixamorigLeftHandMiddle3: "leftMiddleDistal", 24 | mixamorigLeftHandRing1: "leftRingProximal", 25 | mixamorigLeftHandRing2: "leftRingIntermediate", 26 | mixamorigLeftHandRing3: "leftRingDistal", 27 | mixamorigLeftHandPinky1: "leftLittleProximal", 28 | mixamorigLeftHandPinky2: "leftLittleIntermediate", 29 | mixamorigLeftHandPinky3: "leftLittleDistal", 30 | mixamorigRightShoulder: "rightShoulder", 31 | mixamorigRightArm: "rightUpperArm", 32 | mixamorigRightForeArm: "rightLowerArm", 33 | mixamorigRightHand: "rightHand", 34 | mixamorigRightHandPinky1: "rightLittleProximal", 35 | mixamorigRightHandPinky2: "rightLittleIntermediate", 36 | mixamorigRightHandPinky3: "rightLittleDistal", 37 | mixamorigRightHandRing1: "rightRingProximal", 38 | mixamorigRightHandRing2: "rightRingIntermediate", 39 | mixamorigRightHandRing3: "rightRingDistal", 40 | mixamorigRightHandMiddle1: "rightMiddleProximal", 41 | mixamorigRightHandMiddle2: "rightMiddleIntermediate", 42 | mixamorigRightHandMiddle3: "rightMiddleDistal", 43 | mixamorigRightHandIndex1: "rightIndexProximal", 44 | mixamorigRightHandIndex2: "rightIndexIntermediate", 45 | mixamorigRightHandIndex3: "rightIndexDistal", 46 | mixamorigRightHandThumb1: "rightThumbMetacarpal", 47 | mixamorigRightHandThumb2: "rightThumbProximal", 48 | mixamorigRightHandThumb3: "rightThumbDistal", 49 | mixamorigLeftUpLeg: "leftUpperLeg", 50 | mixamorigLeftLeg: "leftLowerLeg", 51 | mixamorigLeftFoot: "leftFoot", 52 | mixamorigLeftToeBase: "leftToes", 53 | mixamorigRightUpLeg: "rightUpperLeg", 54 | mixamorigRightLeg: "rightLowerLeg", 55 | mixamorigRightFoot: "rightFoot", 56 | mixamorigRightToeBase: "rightToes", 57 | }; 58 | -------------------------------------------------------------------------------- /src/index.css: -------------------------------------------------------------------------------- 1 | html { 2 | height: 100%; 3 | width: 100%; 4 | } 5 | 6 | body { 7 | font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, 8 | Arial, sans-serif; 9 | margin: auto; 10 | min-height: "100vh"; 11 | width: "100%"; 12 | } 13 | 14 | #background-image { 15 | background: linear-gradient(123deg, #111827, #060016); 16 | background-size: 400% 400%; 17 | 18 | -webkit-animation: AnimationName 21s ease infinite; 19 | -moz-animation: AnimationName 21s ease infinite; 20 | animation: AnimationName 21s ease infinite; 21 | 22 | position: fixed; 23 | top: 0; 24 | left: 0; 25 | height: 100%; 26 | width: 100%; 27 | z-index: -1; 28 | 29 | @-webkit-keyframes AnimationName { 30 | 0% { 31 | background-position: 10% 0%; 32 | } 33 | 50% { 34 | background-position: 91% 100%; 35 | } 36 | 100% { 37 | background-position: 10% 0%; 38 | } 39 | } 40 | @-moz-keyframes AnimationName { 41 | 0% { 42 | background-position: 10% 0%; 43 | } 44 | 50% { 45 | background-position: 91% 100%; 46 | } 47 | 100% { 48 | background-position: 10% 0%; 49 | } 50 | } 51 | @keyframes AnimationName { 52 | 0% { 53 | background-position: 10% 0%; 54 | } 55 | 50% { 56 | background-position: 91% 100%; 57 | } 58 | 100% { 59 | background-position: 10% 0%; 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Lala Companion 6 | 7 | 8 |
9 | 10 | 11 | -------------------------------------------------------------------------------- /src/main.ts: -------------------------------------------------------------------------------- 1 | import { 2 | app, 3 | BrowserWindow, 4 | ipcMain, 5 | screen, 6 | systemPreferences, 7 | session, 8 | desktopCapturer, 9 | } from "electron"; 10 | import { writeFile } from "fs"; 11 | import { generateText } from "ai"; 12 | import { openai } from "@ai-sdk/openai"; 13 | import dotenv from "dotenv"; 14 | 15 | dotenv.config(); 16 | 17 | // Handle creating/removing shortcuts on Windows when installing/uninstalling. 18 | if (require("electron-squirrel-startup")) { 19 | app.quit(); 20 | } 21 | 22 | let overlayWindow: BrowserWindow = null; 23 | let mainWindow: BrowserWindow = null; 24 | let currentPrompt = ""; 25 | 26 | const createMainWindow = () => { 27 | mainWindow = new BrowserWindow({ 28 | webPreferences: { 29 | preload: MAIN_WINDOW_PRELOAD_WEBPACK_ENTRY, 30 | }, 31 | }); 32 | 33 | mainWindow.loadURL(MAIN_WINDOW_WEBPACK_ENTRY); 34 | 35 | if (process.env.NODE_ENV === "development") { 36 | mainWindow.webContents.openDevTools(); 37 | } 38 | }; 39 | 40 | const createOverlayWindow = ( 41 | withFrame: boolean, 42 | width: number, 43 | height: number 44 | ) => { 45 | overlayWindow = new BrowserWindow({ 46 | webPreferences: { 47 | preload: OVERLAY_WINDOW_PRELOAD_WEBPACK_ENTRY, 48 | }, 49 | height: 800, 50 | width: 500, 51 | alwaysOnTop: true, 52 | transparent: true, 53 | frame: withFrame, 54 | x: width, 55 | y: height, 56 | }); 57 | 58 | overlayWindow.setFocusable(false); 59 | overlayWindow.loadURL(OVERLAY_WINDOW_WEBPACK_ENTRY); 60 | 61 | if (process.env.NODE_ENV === "development") { 62 | overlayWindow.webContents.openDevTools(); 63 | } 64 | }; 65 | 66 | app.on("ready", () => { 67 | const display = screen.getPrimaryDisplay(); 68 | const { width, height } = display.bounds; 69 | 70 | createMainWindow(); 71 | session.defaultSession.webRequest.onHeadersReceived((details, callback) => { 72 | const csp = 73 | "default-src 'self' 'unsafe-eval' 'unsafe-inline' https://lalaland.chat https://fonts.gstatic.com https://cdn.jsdelivr.net file: data: blob: filesystem:; " + 74 | "connect-src 'self' https://lalaland.chat https://fonts.gstatic.com https://cdn.jsdelivr.net file: data: blob: filesystem:; " + 75 | "script-src 'self' 'unsafe-eval' file: data: blob: filesystem:; " + 76 | "style-src 'self' 'unsafe-inline'; " + 77 | "img-src 'self' https://lalaland.chat data:; " + 78 | "media-src 'self' https://lalaland.chat data: blob: filesystem:; " + 79 | "worker-src 'self' 'unsafe-eval' file: data: blob: filesystem:"; 80 | 81 | callback({ 82 | responseHeaders: { 83 | ...details.responseHeaders, 84 | "Content-Security-Policy": [csp], 85 | }, 86 | }); 87 | }); 88 | 89 | if (process.platform === "darwin") { 90 | systemPreferences.askForMediaAccess("microphone"); 91 | } 92 | 93 | ipcMain.on("open-overlay", () => { 94 | createOverlayWindow(false, width, height); 95 | }); 96 | 97 | ipcMain.on("close-overlay", () => { 98 | overlayWindow?.close(); 99 | overlayWindow = null; 100 | }); 101 | 102 | ipcMain.on("open-overlay-frame", () => { 103 | overlayWindow?.close(); 104 | overlayWindow = null; 105 | createOverlayWindow(true, width, height); 106 | }); 107 | 108 | ipcMain.on("close-overlay-frame", () => { 109 | overlayWindow?.close(); 110 | overlayWindow = null; 111 | createOverlayWindow(false, width, height); 112 | }); 113 | 114 | ipcMain.on("send-prompt", (event, prompt: string) => { 115 | overlayWindow?.webContents.send("prompt-sent", prompt); 116 | }); 117 | 118 | ipcMain.on("set-prompt", (event, prompt: string) => { 119 | currentPrompt = prompt; 120 | }); 121 | 122 | ipcMain.on("set-hotmic", (event, isActive: boolean) => { 123 | overlayWindow?.webContents.send("hotmic-toggled", isActive); 124 | }); 125 | 126 | ipcMain.on("set-hotmic", (event, isActive: boolean) => { 127 | overlayWindow?.webContents.send("hotmic-toggled", isActive); 128 | }); 129 | 130 | ipcMain.on("get-screenshot", async () => { 131 | try { 132 | const sources = await desktopCapturer.getSources({ 133 | types: ["screen"], 134 | thumbnailSize: { 135 | width, 136 | height, 137 | }, 138 | }); 139 | 140 | const png = sources[0].thumbnail.toPNG(); 141 | const base64 = png.toString("base64"); 142 | 143 | mainWindow?.webContents.send("screenshot", { 144 | image: base64, 145 | height, 146 | width, 147 | prompt: currentPrompt, 148 | }); 149 | 150 | writeFile("screenshot.png", png, (err) => { 151 | if (err) { 152 | return console.log(err); 153 | } 154 | console.log("The file was saved!"); 155 | }); 156 | } catch (e) { 157 | console.error(e); 158 | } 159 | }); 160 | 161 | const messages: { 162 | role: "user" | "assistant"; 163 | content: string; 164 | }[] = []; 165 | 166 | ipcMain.on("generate-text", async (event, prompt: string) => { 167 | try { 168 | messages.push({ 169 | role: "user", 170 | content: prompt, 171 | }); 172 | 173 | const { text } = await generateText({ 174 | model: openai("gpt-4o"), 175 | prompt: `Reply to the latest message in the conversation. The conversation is: ${messages 176 | .map((message) => `${message.role}: ${message.content}`) 177 | .join("\n")}`, 178 | }); 179 | 180 | messages.push({ 181 | role: "assistant", 182 | content: text, 183 | }); 184 | 185 | overlayWindow?.webContents.send("generated-text", text); 186 | } catch (e) { 187 | console.error(e); 188 | overlayWindow?.webContents.send("error", e); 189 | } 190 | }); 191 | }); 192 | 193 | // Quit when all windows are closed, except on macOS. There, it's common 194 | // for applications and their menu bar to stay active until the user quits 195 | // explicitly with Cmd + Q. 196 | app.on("window-all-closed", () => { 197 | if (process.platform !== "darwin") { 198 | app.quit(); 199 | } 200 | }); 201 | 202 | app.on("activate", () => { 203 | // On OS X it's common to re-create a window in the app when the 204 | // dock icon is clicked and there are no other windows open. 205 | if (BrowserWindow.getAllWindows().length === 0) { 206 | createMainWindow(); 207 | } 208 | }); 209 | -------------------------------------------------------------------------------- /src/overlay/Overlay.tsx: -------------------------------------------------------------------------------- 1 | import React, { useCallback, useEffect, useState } from "react"; 2 | import { useChat } from "@ai-sdk/react"; 3 | import hark from "hark"; 4 | import WaveSurfer from "wavesurfer.js"; 5 | import RecordPlugin from "wavesurfer.js/dist/plugins/record.js"; 6 | import Scene from "../Scene"; 7 | 8 | const Overlay = () => { 9 | const [voiceUrl, setVoiceUrl] = useState(""); 10 | const [recentResponse, setRecentResponse] = useState(""); 11 | const [isLalaSpeaking, setIsLalaSpeaking] = useState(false); 12 | const [isHotMicActive, setIsHotMicActive] = useState(false); 13 | 14 | const getVoiceAudio = useCallback(async (text: string) => { 15 | try { 16 | const voiceResp = await fetch("https://lalaland.chat/api/voice", { 17 | method: "POST", 18 | headers: { 19 | "Content-Type": "application/json", 20 | }, 21 | body: JSON.stringify({ 22 | text, 23 | voiceId: "zrHiDhphv9ZnVXBqCLjz", 24 | voiceProvider: "ElevenLabs", 25 | }), 26 | }); 27 | 28 | if (voiceResp.ok) { 29 | const voiceBlob = await voiceResp.blob(); 30 | const voiceUrl = URL.createObjectURL(voiceBlob); 31 | return voiceUrl; 32 | } else { 33 | console.log("Voice response error", voiceResp); 34 | } 35 | } catch (error) { 36 | console.error(error); 37 | } 38 | }, []); 39 | 40 | const { append } = useChat({ 41 | api: "http://localhost:3001/api/chat", 42 | onFinish: async (data) => { 43 | console.log(data); 44 | setVoiceUrl(await getVoiceAudio(data.content)); 45 | setRecentResponse(data.content); 46 | }, 47 | }); 48 | 49 | useEffect(() => { 50 | (window as any).electronAPI.generateText( 51 | "Your name is Lala. You are a cute, smart, Anime girl AI companion inside the user's computer. Like Cortana from Halo. Greet the user on first message. Tell jokes, teach them, or just hangout. Keep it under 500 characters. Do not use emoijis and do not bracket your response with quotes." 52 | ); 53 | 54 | (window as any).electronAPI?.onGeneratedText((text: string) => { 55 | setRecentResponse(text); 56 | }); 57 | }, []); 58 | 59 | useEffect(() => { 60 | (window as any).electronAPI?.onHotMicToggled((isActive: boolean) => { 61 | setIsHotMicActive(isActive); 62 | }); 63 | 64 | (window as any).electronAPI?.onPromptSent((prompt: string) => { 65 | console.log("prompt", prompt); 66 | (window as any).electronAPI.generateText(prompt); 67 | }); 68 | }, []); 69 | 70 | // whisper chunking magic here 71 | useEffect(() => { 72 | let stream: MediaStream = null; 73 | let speechEvents: hark.Harker = null; 74 | let wavesurfer: WaveSurfer = null; 75 | let recorder: RecordPlugin = null; 76 | let isUserSpeaking = false; 77 | let isLoading = false; 78 | 79 | const main = async () => { 80 | stream = await navigator.mediaDevices.getUserMedia({ audio: true }); 81 | speechEvents = hark(stream); 82 | 83 | wavesurfer = WaveSurfer.create({ 84 | container: "#recorder", 85 | height: 0, 86 | }); 87 | 88 | recorder = wavesurfer.registerPlugin( 89 | RecordPlugin.create({ 90 | scrollingWaveform: true, 91 | renderRecordedAudio: false, 92 | }) 93 | ); 94 | 95 | speechEvents.on("speaking", () => { 96 | if (isLalaSpeaking || isLoading) return; 97 | isUserSpeaking = true; 98 | recorder.startRecording(); 99 | console.log("Started speaking"); 100 | }); 101 | 102 | speechEvents.on("stopped_speaking", () => { 103 | if (isLalaSpeaking) return; 104 | isLoading = true; 105 | recorder.stopRecording(); 106 | isUserSpeaking = false; 107 | console.log("Stopped speaking"); 108 | }); 109 | 110 | recorder.on("record-end", async (blob) => { 111 | console.log("recording stopped"); 112 | const formData = new FormData(); 113 | 114 | const file = new File([blob], "voice.wav", { 115 | type: "audio/wav", 116 | }); 117 | 118 | console.log(file); 119 | 120 | formData.append("file", file); 121 | 122 | const whisperResp = await fetch( 123 | "https://lalaland.chat/api/magic/whisper", 124 | { 125 | method: "POST", 126 | body: formData, 127 | } 128 | ); 129 | 130 | if (whisperResp.ok) { 131 | const whisperText = await whisperResp.json(); 132 | console.log(whisperText); 133 | await append({ 134 | role: "user", 135 | content: whisperText, 136 | }); 137 | setTimeout(() => { 138 | isLoading = false; 139 | }, 5000); 140 | } else { 141 | console.log("error whispering", whisperResp); 142 | isLoading = false; 143 | } 144 | }); 145 | }; 146 | 147 | if (isHotMicActive) { 148 | main(); 149 | } 150 | 151 | return () => { 152 | stream?.getTracks().forEach((track) => track.stop()); 153 | speechEvents?.stop(); 154 | wavesurfer?.destroy(); 155 | recorder?.destroy(); 156 | isUserSpeaking = false; 157 | isLoading = false; 158 | }; 159 | }, [isLalaSpeaking, isHotMicActive]); 160 | 161 | return ( 162 |
168 | setIsLalaSpeaking(true)} 172 | onSpeakEnd={() => setIsLalaSpeaking(false)} 173 | /> 174 |
175 |
176 | ); 177 | }; 178 | 179 | const OverlayLayout = () => { 180 | return ; 181 | }; 182 | 183 | export default OverlayLayout; 184 | -------------------------------------------------------------------------------- /src/overlay/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Lala Companion | Overlay 6 | 7 | 8 |
9 | 10 | 11 | -------------------------------------------------------------------------------- /src/overlay/renderer.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file will automatically be loaded by vite and run in the "renderer" context. 3 | * To learn more about the differences between the "main" and the "renderer" context in 4 | * Electron, visit: 5 | * 6 | * https://electronjs.org/docs/tutorial/application-architecture#main-and-renderer-processes 7 | * 8 | * By default, Node.js integration in this file is disabled. When enabling Node.js integration 9 | * in a renderer process, please be aware of potential security implications. You can read 10 | * more about security risks here: 11 | * 12 | * https://electronjs.org/docs/tutorial/security 13 | * 14 | * To enable Node.js integration in this file, open up `main.ts` and enable the `nodeIntegration` 15 | * flag: 16 | * 17 | * ``` 18 | * // Create the browser window. 19 | * mainWindow = new BrowserWindow({ 20 | * width: 800, 21 | * height: 600, 22 | * webPreferences: { 23 | * nodeIntegration: true 24 | * } 25 | * }); 26 | * ``` 27 | */ 28 | 29 | import "../index.css"; 30 | import { createRoot } from "react-dom/client"; 31 | import Overlay from "./Overlay"; 32 | 33 | console.log( 34 | "👋 This message is being logged by 'overlay/renderer.ts', included via Webpack" 35 | ); 36 | 37 | const root = createRoot(document.getElementById("overlay-root")); 38 | root.render(Overlay()); 39 | -------------------------------------------------------------------------------- /src/preload.ts: -------------------------------------------------------------------------------- 1 | // See the Electron documentation for details on how to use preload scripts: 2 | // https://www.electronjs.org/docs/latest/tutorial/process-model#preload-scripts 3 | 4 | import { contextBridge, ipcRenderer } from "electron"; 5 | 6 | contextBridge.exposeInMainWorld("electronAPI", { 7 | openOverlay: () => ipcRenderer.send("open-overlay"), 8 | 9 | closeOverlay: () => ipcRenderer.send("close-overlay"), 10 | 11 | openOverlayFrame: () => ipcRenderer.send("open-overlay-frame"), 12 | 13 | closeOverlayFrame: () => ipcRenderer.send("close-overlay-frame"), 14 | 15 | sendPrompt: (prompt: string) => ipcRenderer.send("send-prompt", prompt), 16 | 17 | setPrompt: (prompt: string) => ipcRenderer.send("set-prompt", prompt), 18 | 19 | setHotMic: (isActive: boolean) => ipcRenderer.send("set-hotmic", isActive), 20 | 21 | onPromptSent: (callback: (prompt: string) => void) => { 22 | ipcRenderer.on("prompt-sent", (event, prompt) => { 23 | callback(prompt); 24 | }); 25 | }, 26 | 27 | onHotMicToggled: (callback: (isActive: boolean) => void) => { 28 | ipcRenderer.on("hotmic-toggled", (event, isActive) => { 29 | callback(isActive); 30 | }); 31 | }, 32 | 33 | getScreenshot: () => ipcRenderer.send("get-screenshot"), 34 | 35 | onScreenshot: ( 36 | callback: ({ 37 | image, 38 | height, 39 | width, 40 | prompt, 41 | }: { 42 | image: string; 43 | height: number; 44 | width: number; 45 | prompt: string; 46 | }) => void 47 | ) => { 48 | ipcRenderer.on( 49 | "screenshot", 50 | ( 51 | event, 52 | { 53 | image, 54 | height, 55 | width, 56 | prompt, 57 | }: { 58 | image: string; 59 | height: number; 60 | width: number; 61 | prompt: string; 62 | } 63 | ) => { 64 | callback({ image, height, width, prompt }); 65 | } 66 | ); 67 | }, 68 | 69 | generateText: (prompt: string) => ipcRenderer.send("generate-text", prompt), 70 | 71 | onGeneratedText: (callback: (text: string) => void) => { 72 | ipcRenderer.on("generated-text", (event, text) => { 73 | callback(text); 74 | }); 75 | }, 76 | }); 77 | -------------------------------------------------------------------------------- /src/renderer.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file will automatically be loaded by vite and run in the "renderer" context. 3 | * To learn more about the differences between the "main" and the "renderer" context in 4 | * Electron, visit: 5 | * 6 | * https://electronjs.org/docs/tutorial/application-architecture#main-and-renderer-processes 7 | * 8 | * By default, Node.js integration in this file is disabled. When enabling Node.js integration 9 | * in a renderer process, please be aware of potential security implications. You can read 10 | * more about security risks here: 11 | * 12 | * https://electronjs.org/docs/tutorial/security 13 | * 14 | * To enable Node.js integration in this file, open up `main.ts` and enable the `nodeIntegration` 15 | * flag: 16 | * 17 | * ``` 18 | * // Create the browser window. 19 | * mainWindow = new BrowserWindow({ 20 | * width: 800, 21 | * height: 600, 22 | * webPreferences: { 23 | * nodeIntegration: true 24 | * } 25 | * }); 26 | * ``` 27 | */ 28 | 29 | import "./index.css"; 30 | import { createRoot } from "react-dom/client"; 31 | import App from "./App"; 32 | 33 | console.log( 34 | "👋 This message is being logged by 'renderer.ts', included via Webpack" 35 | ); 36 | 37 | const root = createRoot(document.getElementById("root")); 38 | root.render(App()); 39 | -------------------------------------------------------------------------------- /src/theme.ts: -------------------------------------------------------------------------------- 1 | import { createTheme } from "@mui/material"; 2 | import { orange } from "@mui/material/colors"; 3 | 4 | declare module "@mui/material/styles" { 5 | interface Theme { 6 | status: { 7 | danger: string; 8 | }; 9 | } 10 | interface ThemeOptions { 11 | status?: { 12 | danger?: string; 13 | }; 14 | } 15 | } 16 | 17 | export const theme = createTheme({ 18 | palette: { 19 | mode: "dark", 20 | }, 21 | status: { 22 | danger: orange[500], 23 | }, 24 | }); 25 | -------------------------------------------------------------------------------- /src/types.d.ts: -------------------------------------------------------------------------------- 1 | // This allows TypeScript to pick up the magic constants that's auto-generated by Forge's Webpack 2 | // plugin that tells the Electron app where to look for the Webpack-bundled app code (depending on 3 | // whether you're running in development or production). 4 | declare const MAIN_WINDOW_WEBPACK_ENTRY: string; 5 | declare const MAIN_WINDOW_PRELOAD_WEBPACK_ENTRY: string; 6 | 7 | declare const OVERLAY_WINDOW_WEBPACK_ENTRY: string; 8 | declare const OVERLAY_WINDOW_PRELOAD_WEBPACK_ENTRY: string; 9 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "jsx": "react", 4 | "target": "ES6", 5 | "allowJs": true, 6 | "module": "commonjs", 7 | "skipLibCheck": true, 8 | "esModuleInterop": true, 9 | "noImplicitAny": true, 10 | "sourceMap": true, 11 | "baseUrl": ".", 12 | "outDir": "dist", 13 | "moduleResolution": "node", 14 | "resolveJsonModule": true, 15 | "paths": { 16 | "*": ["node_modules/*"] 17 | } 18 | }, 19 | "include": ["src/**/*"] 20 | } 21 | -------------------------------------------------------------------------------- /webpack.main.config.ts: -------------------------------------------------------------------------------- 1 | import type { Configuration } from "webpack"; 2 | import CopyWebpackPlugin from "copy-webpack-plugin"; 3 | 4 | import { rules } from "./webpack.rules"; 5 | import { plugins } from "./webpack.plugins"; 6 | 7 | export const mainConfig: Configuration = { 8 | /** 9 | * This is the main entry point for your application, it's the first file 10 | * that runs in the main process. 11 | */ 12 | entry: "./src/main.ts", 13 | // Put your normal webpack config below here 14 | module: { 15 | rules, 16 | }, 17 | plugins, 18 | resolve: { 19 | extensions: [".js", ".ts", ".jsx", ".tsx", ".css", ".json"], 20 | }, 21 | }; 22 | 23 | // Add CopyWebpackPlugin to copy the assets folder to the output directory 24 | plugins.push( 25 | new CopyWebpackPlugin({ 26 | patterns: [ 27 | { 28 | from: "assets", // source folder in project root 29 | to: "assets", // destination folder in output directory 30 | noErrorOnMissing: true, 31 | }, 32 | ], 33 | }) 34 | ); 35 | -------------------------------------------------------------------------------- /webpack.plugins.ts: -------------------------------------------------------------------------------- 1 | import type { WebpackPluginInstance } from "webpack"; 2 | import ForkTsCheckerWebpackPlugin from "fork-ts-checker-webpack-plugin"; 3 | 4 | export const plugins: WebpackPluginInstance[] = [ 5 | new ForkTsCheckerWebpackPlugin({ 6 | logger: "webpack-infrastructure", 7 | }), 8 | ]; -------------------------------------------------------------------------------- /webpack.renderer.config.ts: -------------------------------------------------------------------------------- 1 | import type { Configuration } from "webpack"; 2 | 3 | import { rules } from "./webpack.rules"; 4 | import { plugins } from "./webpack.plugins"; 5 | 6 | rules.push({ 7 | test: /\.css$/, 8 | use: [{ loader: "style-loader" }, { loader: "css-loader" }], 9 | }); 10 | 11 | export const rendererConfig: Configuration = { 12 | module: { 13 | rules, 14 | }, 15 | plugins, 16 | resolve: { 17 | extensions: [".js", ".ts", ".jsx", ".tsx", ".css"], 18 | }, 19 | }; 20 | -------------------------------------------------------------------------------- /webpack.rules.ts: -------------------------------------------------------------------------------- 1 | import type { ModuleOptions } from "webpack"; 2 | 3 | export const rules: Required["rules"] = [ 4 | // Add support for native node modules 5 | { 6 | // We're specifying native_modules in the test because the asset relocator loader generates a 7 | // "fake" .node file which is really a cjs file. 8 | test: /native_modules[/\\].+\.node$/, 9 | use: "node-loader", 10 | }, 11 | { 12 | test: /[/\\]node_modules[/\\].+\.(m?js|node)$/, 13 | parser: { amd: false }, 14 | use: { 15 | loader: "@vercel/webpack-asset-relocator-loader", 16 | options: { 17 | outputAssetBase: "native_modules", 18 | }, 19 | }, 20 | }, 21 | { 22 | test: /\.tsx?$/, 23 | exclude: /(node_modules|\.webpack)/, 24 | use: { 25 | loader: "ts-loader", 26 | options: { 27 | transpileOnly: true, 28 | }, 29 | }, 30 | }, 31 | ]; 32 | --------------------------------------------------------------------------------