├── .gitignore ├── LICENSE ├── Makefile ├── README.md ├── debian ├── changelog ├── compat ├── control ├── copyright ├── docs ├── rules └── source │ └── format ├── kodivc.c └── model ├── kodivc.lm ├── kodivc.vocab ├── normal.dic └── spelling.dic /.gitignore: -------------------------------------------------------------------------------- 1 | .* 2 | !.gitignore 3 | kodivc 4 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 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 General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | EXECUTABLE=kodivc 2 | MODELDIR=`pkg-config --variable=modeldir pocketsphinx` 3 | LIBS=`pkg-config --cflags --libs pocketsphinx sphinxbase` -lcurl 4 | GITVERSION=`git log --oneline 2>/dev/null | cut -d' ' -f1 | head -1` 5 | 6 | all: 7 | gcc -g -o $(EXECUTABLE) $(EXECUTABLE).c -DGITVERSION=\"$(GITVERSION)\" -DMODELDIR=\"$(MODELDIR)\" $(LIBS) 8 | 9 | clean: 10 | rm -f $(EXECUTABLE) 11 | 12 | install: 13 | install -d $(DESTDIR)/usr/bin $(DESTDIR)/$(MODELDIR)/lm/en/kodivc 14 | install $(EXECUTABLE) $(DESTDIR)/usr/bin/$(EXECUTABLE) 15 | install -m 0644 -t $(DESTDIR)/$(MODELDIR)/lm/en/kodivc model/normal.dic model/spelling.dic model/kodivc.lm 16 | 17 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | __PREFACE:__ This piece of software used to be called _xbmcvc_, because the software it was controlling was called XBMC back in the days. However, [XBMC was renamed to Kodi](http://kodi.tv/introducing-kodi-14/) in August 2014 and thus I decided to change the name of my program to _kodivc_, in an effort to steer away from legacy naming. In this document, unless explicitly stated otherwise, the names Kodi and XBMC (and their derivatives) can be used interchangeably. I am nevertheless sticking with Kodi to keep things up-to-date. 2 | 3 | kodivc 4 | ====== 5 | 6 | _kodivc_ is a program for controlling [Kodi](http://kodi.tv/) with simple voice commands. It uses CMU Sphinx for speech recognition. 7 | 8 | Requirements 9 | ------------ 10 | 11 | To use _kodivc_, the following libraries need to be installed on your system: 12 | 13 | * _pocketsphinx_ (version 0.6 or newer) along with its prerequisite, _sphinxbase_ (both available at [CMU Sphinx downloads](http://cmusphinx.sourceforge.net/wiki/download/)) 14 | * _libcurl_ (shipped with cURL, should be present on most systems; if that's not your case, go to the [libcurl homepage](http://curl.haxx.se/libcurl/)) 15 | 16 | For _kodivc_ to work, you need a Kodi version which supports JSON-RPC API version 3 or higher, which means any pre-11.0 (pre-Eden) or newer version should work. Older releases (including Dharma) are not supported. 17 | 18 | Installation 19 | ------------ 20 | 21 | ### Using PPA ### 22 | 23 | __NOTE:__ This installation method is only available for KodiBuntu, XBMCbuntu Gotham and Ubuntu versions 14.04 (Trusty Tahr) and newer. 24 | 25 | You can install the latest version of _kodivc_ by accessing your Kodi box: 26 | 27 | * using a local console (press _CTRL+ALT+F1_ to switch from graphical mode to text mode; press _CTRL+ALT+F7_ to return to graphical mode) 28 | 29 | * remotely, using [SSH](http://kodi.wiki/view/Ssh) 30 | 31 | and issuing the following commands: 32 | 33 | sudo add-apt-repository -y universe 34 | sudo add-apt-repository -y ppa:kempniu/kodivc 35 | sudo apt-get update 36 | sudo apt-get -y install kodivc 37 | 38 | __NOTE:__ Official _pocketsphinx_ packages for Ubuntu 14.04 and newer are compiled with PulseAudio support enabled and ALSA support disabled. However, neither KodiBuntu nor XBMCbuntu use PulseAudio by default. To test _kodivc_ with KodiBuntu or XBMCbuntu Gotham, you have to install and start PulseAudio. Here is a quick-and-dirty way to do it (for your own good, __please don't do this on a system installed on a hard disk__): 39 | 40 | sudo rm -f /etc/apt/preferences.d/{libasound2-plugins,pulseaudio}.pref 41 | sudo apt-get -y install pulseaudio 42 | # for KodiBuntu 43 | DISPLAY=:0 sudo -u kodi pulseaudio & 44 | # for XBMCbuntu Gotham 45 | DISPLAY=:0 sudo -u xbmc pulseaudio & 46 | 47 | If you install KodiBuntu / XBMCbuntu Gotham on a hard disk, you'll have to properly configure PulseAudio and then configure Kodi to use PulseAudio as its sound sink (this is outside the scope of this document, but the Kodi wiki has [some useful information](http://kodi.wiki/view/PulseAudio)). 48 | 49 | ### Using Git ### 50 | 51 | git clone https://github.com/kempniu/kodivc 52 | cd kodivc 53 | make 54 | make install 55 | 56 | __NOTE:__ the user running _kodivc_ should be allowed to access your sound card. On the Gentoo distribution, for instance, this is achieved by adding the user to the _audio_ group. 57 | 58 | ### Configuring Kodi ### 59 | 60 | _kodivc_ uses JSON-RPC via HTTP for passing commands to Kodi. In order for this to work, you need to go to the proper settings page in Kodi and turn on _Allow remote control via HTTP_ (_Allow control of Kodi via HTTP_ in Helix, _Allow control of XBMC via HTTP_ in Gotham and older versions): 61 | 62 | * in Eden, you'll find it under _System_ -> _Settings_ -> _Network_ -> _Services_ 63 | * in Frodo and newer versions, you'll find it under _System_ -> _Settings_ -> _Services_ -> _Webserver_ 64 | 65 | If you want to control your Kodi instance from another machine, make sure you also turn on _Allow remote control by programs on other systems_ (_Allow programs on other systems to control Kodi_ in Helix, _Allow programs on other systems to control XBMC_ in Gotham and older versions): 66 | 67 | * in Eden, you'll find it under _System_ -> _Settings_ -> _Network_ -> _Services_ 68 | * in Frodo and newer versions, you'll find it under _System_ -> _Settings_ -> _Services_ -> _Remote control_ 69 | 70 | __NOTE:__ for the above settings to be available in Gotham and newer versions, the current settings level has to be at least _Standard_. 71 | 72 | Usage 73 | ----- 74 | 75 | After a successful installation, you should be able to run _kodivc_ by executing: 76 | 77 | kodivc 78 | 79 | At startup, _kodivc_ will initialize the speech recognition library and, after successfully self-calibrating to properly tell silence and speech apart, it will start listening to your commands - if everything went fine, you should get the _Ready for listening!_ message. From the moment you get that message just speak to the microphone (see below for valid commands) - that is all it takes to use the program. 80 | 81 | If you are trying to control a Kodi instance installed on a different machine than the one you're running _kodivc_ on (or your Kodi listens on a non-standard port), pass the correct hostname and port number to _kodivc_ via the __-H__ and __-P__ command line switches, respectively. If you have set a username and a password for JSON-RPC in Kodi, pass them to _kodivc_ via the __-u__ and __-p__ command line switches, respectively. 82 | 83 | By default, _kodivc_ will try to capture speech from the _default_ audio device. If that doesn't work for you, you can specify the audio device you want to capture speech from using the __-D__ command line switch. 84 | 85 | By default, though only when controlling Kodi version 12 (Frodo) or newer, _kodivc_ will display GUI notifications when it hears commands or changes its mode of operation. This behavior can be disabled by using the __-n__ command line switch. 86 | 87 | Please consult the usage message (run _kodivc_ with the __-h__ switch to view it) for an explanation of other command line switches. 88 | 89 | Reading further, you'll come across the term "batch". _kodivc_ listens to commands in batches. A batch starts when you start speaking and ends once a long enough period of silence has been detected. Every batch is reported on the command line, with a line like: 90 | 91 | Heard: "COMMAND1 COMMAND2 ... COMMANDn" 92 | 93 | ### Running in daemon mode ### 94 | 95 | _kodivc_ can also run in the background (in so called daemon mode) so that you don't have to have a terminal open to use it. To enable daemon mode, run _kodivc_ with the __-d__ command line switch. Note that when enabling the daemon mode, you'll almost certainly want to enable logging (using the __-L__ command line switch) to a file or to syslog (check the usage message for details) to be able to read the messages output by _kodivc_. To cleanly shutdown the daemon, send a SIGINT signal to it. Another command line option that comes in handy when using daemon mode is the __-r__ option which enables you to specify a file in which _kodivc_ will save its PID after starting. 96 | 97 | ### Locking ### 98 | 99 | By default, _kodivc_ locks itself after initializing to prevent accidental usage. Say _"KODI"_ to unlock. This has to be the first command in a batch in order to work. Whatever you say afterwards will be executed immediately after unlocking. To lock _kodivc_, say _"OKAY"_. The locking/unlocking feature can be disabled using the __-l__ command line switch. 100 | 101 | ### Normal mode ### 102 | 103 | _kodivc_ always starts in normal mode. This is the mode you'll probably use the most. Valid commands are: 104 | 105 | #### Navigation commands #### 106 | 107 | * _UPWARDS_ 108 | * _DOWNWARDS_ 109 | * _LEFT_ 110 | * _RIGHT_ 111 | * _SELECT_ 112 | * _BACK_ 113 | * _HOME_ 114 | * _CONTEXT_* 115 | * _WEATHER_* 116 | * _PICTURES_* 117 | * _TV_* 118 | * _VIDEOS_* 119 | * _MUSIC_* 120 | * _PROGRAMS_* 121 | * _SETTINGS_* 122 | * _FAVORITES_* 123 | 124 | __NOTE:__ Commands marked with an asterisk (*) are only available in Kodi 12 (Frodo) onwards. 125 | 126 | #### Player commands #### 127 | 128 | * _PLAY_ 129 | * _PAUSE_ 130 | * _STOP_ 131 | * _MENU_* 132 | * _PREVIOUS_ 133 | * _NEXT_ 134 | * _SHUFFLE_ 135 | * _UNSHUFFLE_ 136 | * _REPEAT_ [ _ALL_ | _ONE_ | _OFF_ ] 137 | 138 | __NOTE:__ Commands marked with an asterisk (*) are only available in Kodi 12 (Frodo) onwards. 139 | 140 | __NOTE:__ In Kodi 12 (Frodo) onwards you can also say REPEAT without an argument to cycle through available modes. 141 | 142 | #### Volume commands #### 143 | 144 | * _VOLUME_ [ _TEN_ | _TWENTY_ | _THIRTY_ | _FORTY_ | _FIFTY_ | _SIXTY_ | _SEVENTY_ | _EIGHTY_ | _NINETY_ | _MAX_ ] 145 | * _MUTE_ 146 | * _UNMUTE_ 147 | 148 | #### Command repetition #### 149 | 150 | Some commands can be executed multiple times by using one of the following multiplier commands: 151 | 152 | * _TWO_ 153 | * _THREE_ 154 | * _FOUR_ 155 | * _FIVE_ 156 | 157 | Below is an exhaustive list of commands which can be used with a multiplier: 158 | 159 | * _UPWARDS_ 160 | * _DOWNWARDS_ 161 | * _LEFT_ 162 | * _RIGHT_ 163 | * _NEXT_ 164 | * _PREVIOUS_ 165 | 166 | To use a multiplier, say it after the command, e.g. _"NEXT FOUR"_ will skip four items ahead, _"DOWNWARDS THREE RIGHT FIVE"_ will go down three times and then right five times etc. 167 | 168 | ### Spelling mode (Frodo onwards only) ### 169 | 170 | You can use the spelling mode to input letters and digits, e.g. when performing a search, renaming a movie/album etc. - generally when Kodi displays the onscreen keyboard. Please note, though, that _kodivc_ will __not__ switch to the spelling mode automatically. To enable the spelling mode, say _"SPELL"_ while in normal mode. Switching back to normal mode is possible using three different commands: 171 | 172 | * _ACCEPT_ - closes the onscreen keyboard, accepting the provided input (similar to pressing the ENTER key) 173 | * _CANCEL_ - closes the onscreen keyboard, dismissing the provided input (similar to pressing the ESC key) 174 | * _NORMAL_ - switches to normal mode without closing the onscreen keyboard; this is useful if you want to input special characters which don't have a _kodivc_ command counterpart 175 | 176 | __NOTE:__ Every mode switching command has to be the **only** command in a batch in order to work. 177 | 178 | __NOTE:__ The input field is automatically cleared whenever you enter the spelling mode. (Remember that when you initially spell some letters, then switch to normal mode to enter some fancy characters and then try to switch back to spelling mode.) 179 | 180 | #### Letters #### 181 | 182 | _kodivc_ uses the [NATO phonetic alphabet](http://en.wikipedia.org/wiki/NATO_phonetic_alphabet) for spelling. The reason for that is that single letter recognition is very inaccurate, which shouldn't come as much of a surprise (how often do you spell your surname over the phone and people at the other end get it wrong?). NATO phonetic alphabet usage enables _pocketsphinx_ to recognize the desired letters with much better accuracy. Here is a complete list of letter-related commands: 183 | 184 | * _ALPHA_ 185 | * _BRAVO_ 186 | * _CHARLIE_ 187 | * _DELTA_ 188 | * _ECHO_ 189 | * _FOXTROT_ 190 | * _GOLF_ 191 | * _HOTEL_ 192 | * _INDIA_ 193 | * _JULIET_ 194 | * _KILO_ 195 | * _LIMA_ 196 | * _MIKE_ 197 | * _NOVEMBER_ 198 | * _OSCAR_ 199 | * _PAPA_ 200 | * _QUEBEC_ 201 | * _ROMEO_ 202 | * _SIERRA_ 203 | * _TANGO_ 204 | * _UNIFORM_ 205 | * _VICTOR_ 206 | * _WHISKEY_ 207 | * _X-RAY_ 208 | * _YANKEE_ 209 | * _ZULU_ 210 | 211 | #### Digits #### 212 | 213 | * _ZERO_ 214 | * _ONE_ 215 | * _TWO_ 216 | * _THREE_ 217 | * _FOUR_ 218 | * _FIVE_ 219 | * _SIX_ 220 | * _SEVEN_ 221 | * _EIGHT_ 222 | * _NINE_ 223 | 224 | #### Other characters #### 225 | 226 | * _COLON_ 227 | * _COMMA_ 228 | * _DOT_ 229 | * _HYPHEN_ 230 | * _SPACE_ 231 | 232 | #### Special commands #### 233 | 234 | * _CLEAR_ - clears the input field; this has to be the __only__ command in a batch in order to work 235 | * _LOWER_ - switch to lower case input 236 | * _UPPER_ - switch to upper case input 237 | 238 | Troubleshooting 239 | --------------- 240 | 241 | * If you get the _Ready for listening!_ message but nothing you say to the microphone results in a _Heard: "COMMAND"_ type of line appearing, try the test mode: start _kodivc_ with the __-t__ command line switch, then enter space-separated commands in ALL CAPS, ending a batch by pressing ENTER. Example: 242 | 243 | LEFT TWO SELECT 244 | 245 | You'll probably also want to disable locking for testing, so add the __-l__ switch to the command line as well. 246 | 247 | If your Kodi instance properly responds to commands entered in test mode, but doesn't react to anything you say, these are the most common causes of problems: 248 | 249 | * capturing from the wrong device, 250 | * capture levels set too low, too high (yes, overly high sensitivity is also a problem) or muted, 251 | * speaking too quietly. 252 | 253 | * If after starting _kodivc_ you see a series of odd lines among the normal ones, like below: 254 | 255 | Initializing, please wait... 256 | 256x13 256x13 256x13 257 | 256x13 256x13 256x13 258 | Ready for listening! 259 | 260 | just ignore them. It's a known issue with _pocketsphinx_ 0.6. These lines shouldn't appear when using _pocketsphinx_ 0.7 or newer. 261 | 262 | * If after starting _kodivc_ you get a _Failed to open audio device_ message, you are probably facing one of two issues: 263 | * you're using a version of _pocketsphinx_ which uses the PulseAudio backend, but PulseAudio server isn't started, 264 | * the user you're running _kodivc_ as is not allowed to access the audio device you're trying to capture speech from; to confirm, try running _kodivc_ as root - if it works fine, you're facing a permissions-related issue. 265 | 266 | * If after starting _kodivc_ you get an error saying _Failed to calibrate voice activity detection_, please check your mixer levels for capturing audio. 267 | 268 | Language support 269 | ---------------- 270 | 271 | Currently _kodivc_ only supports voice commands spoken in English. Additional languages may be added in the future. 272 | 273 | Caveats 274 | ------- 275 | 276 | In normal mode, _kodivc_ will perform a maximum of 5 actions at a time to avoid confusion. You can say more voice commands than that, but only the first five recognized commands will be executed. 277 | 278 | Feedback 279 | -------- 280 | 281 | I'm always happy to hear feedback. If you encounter a problem with _kodivc_ or you want to share an idea for a new feature, feel free to [create an issue](https://github.com/kempniu/kodivc/issues) at GitHub. Here are some tips for creating a useful bug report: 282 | 283 | * Be as exhaustive as possible. 284 | 285 | * If possible, describe the steps required to reproduce the bug. 286 | 287 | * Include version information for _kodivc_, _sphinxbase_ and _pocketsphinx_ in the report. In KodiBuntu / XBMCbuntu / Ubuntu you can use the following command to retrieve the relevant information: 288 | 289 | dpkg -s kodivc libsphinxbase1 libpocketsphinx1 | grep '\(Package\|Version\)' 290 | 291 | If you built _kodivc_ from Git, please include the output of the following command in the report: 292 | 293 | kodivc -V 294 | 295 | * If available (must be enabled explicitly using the __-L__ command line switch), attach the log file to the report. If you didn't enable logging but you can still get hold of the messages output by _kodivc_ to the console before the crash, please save them to a file and attach that file to the report. 296 | 297 | * If you experienced a segfault, please generate a backtrace and attach it to the report. _gdb_ is required to do that. In KodiBuntu / XBMCbuntu / Ubuntu you can install _gdb_ by running the following command: 298 | 299 | sudo apt-get -y install gdb 300 | 301 | _kodivc_ generates core dumps by default, so all that is required to generate a backtrace is running the following command after _kodivc_ crashes: 302 | 303 | gdb --batch --se kodivc --core core -ex 'bt full' > kodivc-backtrace.txt 2>&1 304 | 305 | The backtrace will be written to file _kodivc-backtrace.txt_. Ensure your core dump is named _core_ - it differs between systems and thus the core dump may be placed in a file like _core.12345_ or similar - just supply the proper core dump file name to _gdb_ using the __--core__ option. Please note that if the segfault happened while _kodivc_ was running in daemon mode, the core dump will be placed in the _/tmp_ directory. 306 | 307 | If you don't have a GitHub account and you don't really want to create one, feel free to post in the [_kodivc_ thread at the Kodi forums](http://forum.kodi.tv/showthread.php?tid=123621) or [catch me on Twitter](http://twitter.com/kempniu). 308 | 309 | -------------------------------------------------------------------------------- /debian/changelog: -------------------------------------------------------------------------------- 1 | kodivc (0.5-1) lucid; urgency=low 2 | 3 | * New upstream release 4 | * Package name changed 5 | 6 | -- Michał Kępień Thu, 08 Jan 2015 11:21:25 +0100 7 | 8 | xbmcvc (0.4-1) lucid; urgency=low 9 | 10 | * New upstream release 11 | 12 | -- Michał Kępień Thu, 24 Jan 2013 08:52:11 +0100 13 | 14 | xbmcvc (0.3-7) lucid; urgency=low 15 | 16 | * Moved to a new PPA source 17 | 18 | -- Michał Kępień Wed, 23 Jan 2013 15:38:49 +0100 19 | -------------------------------------------------------------------------------- /debian/compat: -------------------------------------------------------------------------------- 1 | 7 2 | -------------------------------------------------------------------------------- /debian/control: -------------------------------------------------------------------------------- 1 | Source: kodivc 2 | Section: utils 3 | Priority: extra 4 | Maintainer: Michał Kępień 5 | Build-Depends: quilt (>= 0.46-7~), 6 | debhelper (>= 7), 7 | debhelper (>= 7.0.50~), 8 | libsphinxbase-dev (>= 0.6), 9 | libsphinxbase1 (>= 0.6), 10 | libpocketsphinx1 (>= 0.6), 11 | libpocketsphinx-dev (>= 0.6), 12 | libcurl4-openssl-dev (>= 7.19) 13 | Standards-Version: 3.8.4 14 | Homepage: https://github.com/kempniu/kodivc 15 | 16 | Package: kodivc 17 | Architecture: any 18 | Depends: ${shlibs:Depends}, 19 | ${misc:Depends}, 20 | libsphinxbase1 (>= 0.6), 21 | libpocketsphinx1 (>= 0.6), 22 | pocketsphinx-hmm-en-hub4wsj (>= 0.6), 23 | libcurl3 (>= 7.19) 24 | Description: A program for controlling Kodi with simple voice commands 25 | 26 | -------------------------------------------------------------------------------- /debian/copyright: -------------------------------------------------------------------------------- 1 | This work was packaged for Debian by: 2 | 3 | Michał Kępień on Wed, 23 Jan 2013 15:38:49 +0100 4 | 5 | It was downloaded from: 6 | 7 | https://launchpad.net/~kempniu/+archive/kodivc 8 | 9 | Upstream Author(s): 10 | 11 | Michał Kępień 12 | 13 | Copyright: 14 | 15 | Copyright (C) 2012-2015 Michał Kępień 16 | 17 | License: 18 | 19 | This program is free software: you can redistribute it and/or modify 20 | it under the terms of the GNU General Public License as published by 21 | the Free Software Foundation, either version 3 of the License, or 22 | (at your option) any later version. 23 | 24 | This package is distributed in the hope that it will be useful, 25 | but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 27 | GNU General Public License for more details. 28 | 29 | You should have received a copy of the GNU General Public License 30 | along with this program. If not, see . 31 | 32 | On Debian systems, the complete text of the GNU General 33 | Public License version 3 can be found in `/usr/share/common-licenses/GPL-3'. 34 | 35 | The Debian packaging is: 36 | 37 | Copyright (C) 2015 Michał Kępień 38 | 39 | and is licensed under the GPL version 3, see above. 40 | 41 | -------------------------------------------------------------------------------- /debian/docs: -------------------------------------------------------------------------------- 1 | README.md 2 | -------------------------------------------------------------------------------- /debian/rules: -------------------------------------------------------------------------------- 1 | #!/usr/bin/make -f 2 | # -*- makefile -*- 3 | # Sample debian/rules that uses debhelper. 4 | # This file was originally written by Joey Hess and Craig Small. 5 | # As a special exception, when this file is copied by dh-make into a 6 | # dh-make output file, you may use that output file without restriction. 7 | # This special exception was added by Craig Small in version 0.37 of dh-make. 8 | 9 | # Uncomment this to turn on verbose mode. 10 | #export DH_VERBOSE=1 11 | 12 | %: 13 | dh --with quilt $@ 14 | -------------------------------------------------------------------------------- /debian/source/format: -------------------------------------------------------------------------------- 1 | 3.0 (quilt) 2 | -------------------------------------------------------------------------------- /kodivc.c: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * kodivc - a program for controlling Kodi with simple voice commands 4 | * 5 | * Copyright (C) Michal Kepien, 2012-2015. 6 | * 7 | * The listening code is heavily based on the sample continuous listening 8 | * program (continuous.c) provided along with pocketsphinx. 9 | * 10 | * This program is free software; you can redistribute it and/or modify 11 | * it under the terms of the GNU General Public License as published by 12 | * the Free Software Foundation; either version 2 of the License, or 13 | * (at your option) any later version. 14 | * 15 | * This program is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU General Public License 21 | * along with this program; see the file LICENSE. If not, write to 22 | * the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, 23 | * Boston, MA 02110-1301 USA 24 | * 25 | */ 26 | 27 | /* CURL headers */ 28 | #include 29 | 30 | /* pocketsphinx headers */ 31 | #include 32 | #include 33 | #include 34 | 35 | /* Other headers */ 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | #include 47 | #include 48 | #include 49 | #include 50 | #include 51 | 52 | /* Constants */ 53 | #define VERSION "0.5" 54 | #define USAGE_MESSAGE "\n" \ 55 | "Usage: kodivc [ -H ] [ -P ] [ -u ] [ -p ]\n" \ 56 | " [ -d ] [ -D ] [ -l ] [ -L |syslog ] [ -n ]\n" \ 57 | " [ -r ] [ -t ] [ -V ] [ -h ]\n" \ 58 | "\n" \ 59 | " -H Hostname or IP address of the Kodi instance you want\n" \ 60 | " to control (default: localhost)\n" \ 61 | " -P Port number the Kodi instance you want to control\n" \ 62 | " is listening on (default: 8080)\n" \ 63 | " -u JSON-RPC username (only required if set in Kodi)\n" \ 64 | " -p JSON-RPC password (only required if set in Kodi)\n" \ 65 | " -d Run in daemon mode\n" \ 66 | " -D Name of audio device to capture speech from\n" \ 67 | " -l Disable locking/unlocking\n" \ 68 | " -L |syslog Enable logging to file (supply path)\n" \ 69 | " or to syslog (supply \"syslog\")\n" \ 70 | " -n Disable GUI notifications\n" \ 71 | " -r Write PID to supplied pidfile\n" \ 72 | " -t Enable test mode - enter commands on stdin\n" \ 73 | " -V Print version information and exit\n" \ 74 | " -h Print this help message\n" \ 75 | "\n" 76 | 77 | #define COMMAND_UNLOCK "KODI" 78 | #define COMMAND_LOCK "OKAY" 79 | #define JSON_RPC_DEFAULT_HOST "localhost" 80 | #define JSON_RPC_DEFAULT_PORT 8080 81 | #define JSON_RPC_URL "http://%s:%s/jsonrpc" 82 | #define JSON_RPC_URL_AUTH "http://%s:%s@%s:%s/jsonrpc" 83 | #define JSON_RPC_POST "{\"jsonrpc\":\"2.0\",\"method\":\"%s\",\"id\":1}" 84 | #define JSON_RPC_POST_WITH_PARAMS "{\"jsonrpc\":\"2.0\",\"method\":\"%s\",\"params\":{%s},\"id\":1}" 85 | #define MAX_ACTIONS 5 86 | #define SPELLING_BUFFER_SIZE 256 87 | #define KODI_VERSION_EDEN 11 88 | #define KODI_VERSION_FRODO 12 89 | #define KODI_VERSION_GOTHAM 13 90 | #define KODI_VERSION_HELIX 14 91 | #define KODI_VERSION_ISENGARD 15 92 | #define KODI_VERSION_MIN KODI_VERSION_EDEN 93 | #define KODI_VERSION_MAX KODI_VERSION_ISENGARD 94 | 95 | /* Language model files */ 96 | #define MODEL_HMM MODELDIR "/hmm/en_US/hub4wsj_sc_8k" 97 | #define MODEL_LM MODELDIR "/lm/en/kodivc/kodivc.lm" 98 | #define MODEL_DICT MODELDIR "/lm/en/kodivc/normal.dic" 99 | 100 | /* Macros */ 101 | #define ARRAY_SIZE(array) (sizeof(array) / sizeof(array[0])) 102 | 103 | /* Modes of operation */ 104 | enum mode_t { 105 | MODE_NORMAL, 106 | MODE_SPELLING, 107 | MODE_NONE, 108 | }; 109 | 110 | /* Structure passed to CURL callback */ 111 | typedef struct { 112 | char** dst; /* destination buffer */ 113 | int dst_s; /* destination buffer size */ 114 | } curl_userdata_t; 115 | 116 | /* Structure describing an action */ 117 | typedef struct { 118 | char* word; 119 | char* method; 120 | char* params; 121 | const char** req; 122 | int req_size; 123 | int repeats; 124 | int needs_player_id; 125 | int needs_argument; 126 | } action_t; 127 | 128 | /* Command to character mapping */ 129 | typedef struct { 130 | char* string; 131 | int character; 132 | } cmap_t; 133 | 134 | /* Names of modes of operation */ 135 | const char* loglevels[] = { "EMERGENCY", "ALERT", "CRITICAL", "ERROR", "WARNING", "NOTICE", "INFO", "DEBUG" }; 136 | const char* modes[] = { "normal", "spelling" }; 137 | 138 | /* Global configuration variables */ 139 | char* config_json_rpc_host; 140 | char* config_json_rpc_port; 141 | char* config_json_rpc_username; 142 | char* config_json_rpc_password; 143 | int config_daemon = 0; 144 | char* config_audio_device; 145 | int config_locking = 1; 146 | FILE* config_logfile; 147 | int config_syslog = 0; 148 | int config_notifications = 1; 149 | char* config_pidfile; 150 | int config_test_mode = 0; 151 | 152 | /* Action database */ 153 | action_t** actions = NULL; 154 | int actions_count = 0; 155 | const char* repeatable[] = { "DOWNWARDS", "LEFT", "NEXT", "PREVIOUS", "RIGHT", "UPWARDS" }; 156 | int repeatable_size = ARRAY_SIZE(repeatable); 157 | const char* repeat_args[] = { "ALL:all", "ONE:one", "OFF:off", "cycle" }; 158 | int repeat_args_size = ARRAY_SIZE(repeat_args); 159 | const char* volume_args[] = { "TEN:10", "TWENTY:20", "THIRTY:30", "FORTY:40", "FIFTY:50", "SIXTY:60", "SEVENTY:70", "EIGHTY:80", "NINETY:90", "MAX:100" }; 160 | int volume_args_size = ARRAY_SIZE(volume_args); 161 | 162 | /* Command to character mapping database */ 163 | cmap_t** cmap = NULL; 164 | int cmap_count = 0; 165 | 166 | /* Miscellaneous variables */ 167 | int locked = 1; 168 | mode_t mode = MODE_NORMAL; 169 | char spelling_buffer[SPELLING_BUFFER_SIZE]; 170 | int spelling_case = 0; 171 | int kodi_version; 172 | 173 | /* Exit flag */ 174 | volatile sig_atomic_t exit_flag = 0; 175 | 176 | /*---------------------------------------------------------------------------*/ 177 | 178 | void 179 | set_exit_flag(int signal) 180 | { 181 | exit_flag = 1; 182 | } 183 | 184 | void 185 | cleanup(void) 186 | { 187 | 188 | int i; 189 | 190 | /* Pidfile */ 191 | if (config_pidfile) 192 | unlink(config_pidfile); 193 | 194 | /* Filehandles */ 195 | if (config_logfile) 196 | fclose(config_logfile); 197 | else if (config_syslog) 198 | closelog(); 199 | 200 | /* Configuration */ 201 | free(config_json_rpc_host); 202 | free(config_json_rpc_port); 203 | free(config_json_rpc_username); 204 | free(config_json_rpc_password); 205 | free(config_audio_device); 206 | free(config_pidfile); 207 | 208 | /* Actions database */ 209 | for (i=0; iword); 212 | free(actions[i]->method); 213 | free(actions[i]->params); 214 | free(actions[i]->req); 215 | free(actions[i]); 216 | } 217 | free(actions); 218 | 219 | /* Command to character mapping */ 220 | for (i=0; istring); 223 | free(cmap[i]); 224 | } 225 | free(cmap); 226 | 227 | } 228 | 229 | void 230 | vprint_log(const int level, const char* format, va_list args) 231 | { 232 | 233 | time_t now; 234 | char timestamp[32]; 235 | va_list args_copy; 236 | 237 | if (!config_daemon) 238 | { 239 | printf("%s: ", loglevels[level]); 240 | va_copy(args_copy, args); 241 | vprintf(format, args_copy); 242 | va_end(args_copy); 243 | printf("\n"); 244 | } 245 | 246 | if (config_logfile) 247 | { 248 | now = time(NULL); 249 | snprintf(timestamp, 32, "%s", asctime(localtime(&now))); 250 | /* Trim newline */ 251 | *(timestamp + strlen(timestamp) - 1) = '\0'; 252 | fprintf(config_logfile, "%s kodivc[%d]: %s: ", timestamp, getpid(), loglevels[level]); 253 | va_copy(args_copy, args); 254 | vfprintf(config_logfile, format, args_copy); 255 | va_end(args_copy); 256 | fprintf(config_logfile, "\n"); 257 | } 258 | else if (config_syslog) 259 | { 260 | va_copy(args_copy, args); 261 | vsyslog(level, format, args_copy); 262 | va_end(args_copy); 263 | } 264 | 265 | } 266 | 267 | void 268 | print_log(const int level, const char* format, ...) 269 | { 270 | va_list args; 271 | va_start(args, format); 272 | vprint_log(level, format, args); 273 | va_end(args); 274 | } 275 | 276 | void 277 | die(const char* format, ...) 278 | { 279 | va_list args; 280 | va_start(args, format); 281 | vprint_log(LOG_CRIT, format, args); 282 | va_end(args); 283 | exit(1); 284 | } 285 | 286 | void 287 | parse_options(int argc, char* argv[]) 288 | { 289 | 290 | int option; 291 | int quit = 0; 292 | FILE* pidfile; 293 | 294 | /* Initialize default values */ 295 | config_json_rpc_host = malloc(strlen(JSON_RPC_DEFAULT_HOST) + 1); 296 | config_json_rpc_port = malloc(6); 297 | config_json_rpc_username = NULL; 298 | config_json_rpc_password = NULL; 299 | config_audio_device = NULL; 300 | config_logfile = NULL; 301 | config_pidfile = NULL; 302 | 303 | assert(config_json_rpc_host); 304 | sprintf(config_json_rpc_host, "%s", JSON_RPC_DEFAULT_HOST); 305 | assert(config_json_rpc_port); 306 | snprintf(config_json_rpc_port, 6, "%d", JSON_RPC_DEFAULT_PORT); 307 | 308 | /* Process command line options */ 309 | while ((option = getopt(argc, argv, "H:P:u:p:dD:lL:nr:tVh")) != -1 && !quit) 310 | { 311 | switch(option) 312 | { 313 | 314 | /* Kodi host */ 315 | case 'H': 316 | config_json_rpc_host = realloc(config_json_rpc_host, strlen(optarg) + 1); 317 | assert(config_json_rpc_host); 318 | sprintf(config_json_rpc_host, "%s", optarg); 319 | break; 320 | 321 | /* Kodi port */ 322 | case 'P': 323 | snprintf(config_json_rpc_port, 6, "%s", optarg); 324 | break; 325 | 326 | /* Kodi username */ 327 | case 'u': 328 | config_json_rpc_username = malloc(strlen(optarg) + 1); 329 | assert(config_json_rpc_username); 330 | sprintf(config_json_rpc_username, "%s", optarg); 331 | break; 332 | 333 | /* Kodi password */ 334 | case 'p': 335 | config_json_rpc_password = malloc(strlen(optarg) + 1); 336 | assert(config_json_rpc_password); 337 | sprintf(config_json_rpc_password, "%s", optarg); 338 | break; 339 | 340 | /* Daemon mode */ 341 | case 'd': 342 | config_daemon = 1; 343 | break; 344 | 345 | /* audio capture device */ 346 | case 'D': 347 | config_audio_device = realloc(config_audio_device, strlen(optarg) + 1); 348 | assert(config_audio_device); 349 | sprintf(config_audio_device, "%s", optarg); 350 | break; 351 | 352 | /* Locking */ 353 | case 'l': 354 | config_locking = 0; 355 | break; 356 | 357 | /* Logging */ 358 | case 'L': 359 | if (strcmp(optarg, "syslog") == 0) 360 | { 361 | openlog("kodivc", LOG_PID, LOG_USER); 362 | config_syslog = 1; 363 | } 364 | else 365 | { 366 | config_logfile = fopen(optarg, "a"); 367 | if (config_logfile == NULL) 368 | die("Unable to open logfile %s", optarg); 369 | } 370 | break; 371 | 372 | /* Notifications */ 373 | case 'n': 374 | config_notifications = 0; 375 | break; 376 | 377 | /* Pidfile */ 378 | case 'r': 379 | if (access(optarg, R_OK) == 0) 380 | die("Pidfile %s already exists", optarg); 381 | pidfile = fopen(optarg, "w"); 382 | if (pidfile == NULL) 383 | die("Failed to write PID to %s", optarg); 384 | fprintf(pidfile, "%d", getpid()); 385 | fclose(pidfile); 386 | config_pidfile = malloc(strlen(optarg) + 1); 387 | assert(config_pidfile); 388 | sprintf(config_pidfile, "%s", optarg); 389 | break; 390 | 391 | /* Test mode */ 392 | case 't': 393 | config_test_mode = 1; 394 | break; 395 | 396 | /* Version information */ 397 | case 'V': 398 | printf("kodivc " VERSION); 399 | if (strlen(GITVERSION) > 0) 400 | printf(" (Git: " GITVERSION ")"); 401 | printf("\n"); 402 | quit = 1; 403 | break; 404 | 405 | /* Help or unknown option */ 406 | case 'h': 407 | default: 408 | printf(USAGE_MESSAGE); 409 | quit = 1; 410 | break; 411 | 412 | } 413 | } 414 | 415 | /* Error checks */ 416 | if (config_test_mode && config_daemon) 417 | die("Daemon mode and test mode are mutually exclusive"); 418 | if (config_json_rpc_username && !config_json_rpc_password) 419 | die("Password must be provided along with username"); 420 | if (config_json_rpc_password && !config_json_rpc_username) 421 | die("Username must be provided along with password"); 422 | 423 | /* Quit if appropriate */ 424 | if (quit) 425 | exit(0); 426 | 427 | } 428 | 429 | int 430 | in_array(const char* haystack[], const int haystack_size, const char* needle) 431 | { 432 | int found = 0; 433 | int i = 0; 434 | while (i < haystack_size && !found) 435 | { 436 | if (strcmp(haystack[i++], needle) == 0) 437 | found = 1; 438 | } 439 | return found; 440 | } 441 | 442 | void 443 | append_param(char** current, const char* append) 444 | { 445 | if (*current) 446 | { 447 | *current = realloc(*current, strlen(*current) + strlen(append) + 2); 448 | assert(*current); 449 | strcat(*current, ","); 450 | } 451 | else 452 | { 453 | *current = malloc(strlen(append) + 1); 454 | assert(*current); 455 | **current = '\0'; 456 | } 457 | strcat(*current, append); 458 | } 459 | 460 | /* CURL callback for saving HTTP response to a pointer passed via userdata */ 461 | size_t 462 | save_response_in_memory(const char* ptr, const size_t size, const size_t nmemb, void* userdata) 463 | { 464 | curl_userdata_t* cud = (curl_userdata_t *) userdata; 465 | *cud->dst = realloc(*cud->dst, cud->dst_s + (size * nmemb) + 1); 466 | assert(*cud->dst); 467 | memcpy(*cud->dst + cud->dst_s, ptr, size * nmemb); 468 | cud->dst_s += size * nmemb; 469 | /* Null-terminate response for easier handling */ 470 | *(*cud->dst + cud->dst_s) = '\0'; 471 | return size * nmemb; 472 | } 473 | 474 | int 475 | send_json_rpc_request(const char* method, const char* params, char** dst) 476 | { 477 | 478 | CURL* curl; 479 | CURLcode result; 480 | char* url; 481 | char* post; 482 | char* response = NULL; 483 | curl_userdata_t cud; 484 | struct curl_slist* headers = NULL; 485 | 486 | /* Prepare JSON-RPC URL */ 487 | if (config_json_rpc_username && config_json_rpc_password) 488 | { 489 | url = malloc( 490 | strlen(JSON_RPC_URL_AUTH) 491 | + strlen(config_json_rpc_username) 492 | + strlen(config_json_rpc_password) 493 | + strlen(config_json_rpc_host) 494 | + strlen(config_json_rpc_port) 495 | ); 496 | assert(url); 497 | sprintf(url, JSON_RPC_URL_AUTH, config_json_rpc_username, config_json_rpc_password, config_json_rpc_host, config_json_rpc_port); 498 | } 499 | else 500 | { 501 | url = malloc( 502 | strlen(JSON_RPC_URL) 503 | + strlen(config_json_rpc_host) 504 | + strlen(config_json_rpc_port) 505 | ); 506 | assert(url); 507 | sprintf(url, JSON_RPC_URL, config_json_rpc_host, config_json_rpc_port); 508 | } 509 | 510 | /* Prepare POST data with or without parameters */ 511 | if (params == NULL) 512 | { 513 | post = malloc(strlen(JSON_RPC_POST) + strlen(method)); 514 | assert(post); 515 | sprintf(post, JSON_RPC_POST, method); 516 | } 517 | else 518 | { 519 | post = malloc(strlen(JSON_RPC_POST_WITH_PARAMS) + strlen(method) + strlen(params)); 520 | assert(post); 521 | sprintf(post, JSON_RPC_POST_WITH_PARAMS, method, params); 522 | } 523 | 524 | /* Initialize userdata structure passed to callback */ 525 | cud.dst = &response; 526 | cud.dst_s = 0; 527 | 528 | /* Initialize libcurl */ 529 | if ((curl = curl_easy_init()) == NULL) 530 | die("Error initializing libcurl"); 531 | 532 | /* Set request options */ 533 | curl_easy_setopt(curl, CURLOPT_URL, url); 534 | curl_easy_setopt(curl, CURLOPT_POST, 1); 535 | curl_easy_setopt(curl, CURLOPT_POSTFIELDS, post); 536 | curl_easy_setopt(curl, CURLOPT_TIMEOUT, 2); 537 | curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, save_response_in_memory); 538 | curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *) &cud); 539 | 540 | /* Add proper Content-Type header */ 541 | headers = curl_slist_append(headers, "Content-Type: application/json"); 542 | curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers); 543 | 544 | /* Send JSON-RPC request */ 545 | result = curl_easy_perform(curl); 546 | if (result != 0) 547 | print_log(LOG_WARNING, "Kodi instance at %s:%s is not responding", config_json_rpc_host, config_json_rpc_port); 548 | 549 | /* If caller provided a pointer, save response there (if it exists) */ 550 | if (dst && response) 551 | { 552 | *dst = realloc(*dst, strlen(response) + 1); 553 | assert(*dst); 554 | strcpy(*dst, response); 555 | } 556 | 557 | /* Cleanup */ 558 | free(response); 559 | free(post); 560 | free(url); 561 | curl_slist_free_all(headers); 562 | curl_easy_cleanup(curl); 563 | 564 | return (int) result; 565 | 566 | } 567 | 568 | void 569 | send_gui_notification(const char* title, const char* message, const char* icon) 570 | { 571 | 572 | const char* format = "\"title\":\"%s\",\"message\":\"%s\",\"image\":\"%s\""; 573 | char* params; 574 | 575 | if (kodi_version >= KODI_VERSION_FRODO && config_notifications) 576 | { 577 | params = malloc(strlen(format) + strlen(title) + strlen(message) + strlen(icon)); 578 | assert(params); 579 | sprintf(params, format, title, message, icon); 580 | send_json_rpc_request("GUI.ShowNotification", params, NULL); 581 | free(params); 582 | } 583 | 584 | } 585 | 586 | int 587 | get_json_rpc_response_int(const char* method, const char* params, const char* param) 588 | { 589 | 590 | char* response = NULL; 591 | char* result; 592 | char* param_search = NULL; 593 | char* param_string; 594 | char param_value[4]; 595 | unsigned int i = 0; 596 | int retval = -1; 597 | 598 | if (send_json_rpc_request(method, params, &response) != 0 || !response) 599 | return -2; 600 | 601 | result = strstr(response, "\"result\":"); 602 | if (result) 603 | { 604 | result += strlen("\"result\":") + 1; 605 | param_search = malloc(strlen(param) + 4); 606 | assert(param_search); 607 | sprintf(param_search, "\"%s\":", param); 608 | param_string = strstr(result, param_search); 609 | if (param_string) 610 | { 611 | memset(param_value, 0, sizeof(param_value)); 612 | param_string += strlen(param) + 3; 613 | while(i < sizeof(param_value) && *param_string >= '0' && *param_string <= '9') 614 | { 615 | param_value[i] = *param_string; 616 | param_string++; 617 | i++; 618 | } 619 | if (i == 0) 620 | retval = -1; 621 | else 622 | retval = atoi(param_value); 623 | } 624 | free(param_search); 625 | } 626 | free(response); 627 | 628 | return retval; 629 | 630 | } 631 | 632 | void 633 | register_action(const char* word, const char* method, const char* params, const char* req[], const int req_size, const int repeats, const int needs_player_id, const int needs_argument) 634 | { 635 | 636 | /* Allocate memory for action structure */ 637 | action_t* a = malloc(sizeof(action_t)); 638 | assert(a); 639 | 640 | /* Copy function arguments to structure fields */ 641 | a->word = strdup(word); 642 | 643 | if (method) 644 | a->method = strdup(method); 645 | else 646 | a->method = NULL; 647 | 648 | if (params) 649 | a->params = strdup(params); 650 | else 651 | a->params = NULL; 652 | 653 | if (req) 654 | { 655 | a->req = calloc(req_size, sizeof(char *)); 656 | assert(a->req); 657 | memcpy(a->req, req, req_size * sizeof(char *)); 658 | } 659 | else 660 | { 661 | a->req = NULL; 662 | } 663 | 664 | a->req_size = req_size; 665 | a->repeats = repeats; 666 | a->needs_player_id = needs_player_id; 667 | a->needs_argument = needs_argument; 668 | 669 | /* Expand action database */ 670 | actions = realloc(actions, (actions_count + 1) * sizeof(action_t *)); 671 | assert(actions); 672 | /* Add action to database */ 673 | actions[actions_count] = a; 674 | actions_count++; 675 | 676 | } 677 | 678 | void 679 | initialize_actions(void) 680 | { 681 | 682 | /* General actions */ 683 | register_action("BACK", "Input.Back", NULL, NULL, 0, 1, 0, 0); 684 | register_action("DOWNWARDS", "Input.Down", NULL, NULL, 0, 1, 0, 0); 685 | register_action("HOME", "Input.Home", NULL, NULL, 0, 1, 0, 0); 686 | register_action("LEFT", "Input.Left", NULL, NULL, 0, 1, 0, 0); 687 | register_action("MUTE", "Application.SetMute", "\"mute\": true", NULL, 0, 1, 0, 0); 688 | register_action("RIGHT", "Input.Right", NULL, NULL, 0, 1, 0, 0); 689 | register_action("SELECT", "Input.Select", NULL, NULL, 0, 1, 0, 0); 690 | register_action("UNMUTE", "Application.SetMute", "\"mute\": false", NULL, 0, 1, 0, 0); 691 | register_action("UPWARDS", "Input.Up", NULL, NULL, 0, 1, 0, 0); 692 | register_action("VOLUME", "Application.SetVolume", "\"volume\":%s", volume_args, volume_args_size, 1, 0, 1); 693 | 694 | /* Repeating actions */ 695 | register_action("TWO", NULL, NULL, repeatable, repeatable_size, 2, 0, 0); 696 | register_action("THREE", NULL, NULL, repeatable, repeatable_size, 3, 0, 0); 697 | register_action("FOUR", NULL, NULL, repeatable, repeatable_size, 4, 0, 0); 698 | register_action("FIVE", NULL, NULL, repeatable, repeatable_size, 5, 0, 0); 699 | 700 | /* Version-dependent actions */ 701 | switch(kodi_version) 702 | { 703 | 704 | case KODI_VERSION_EDEN: 705 | register_action("NEXT", "Player.GoNext", NULL, NULL, 0, 1, 1, 0); 706 | register_action("PAUSE", "Player.PlayPause", NULL, NULL, 0, 1, 1, 0); 707 | register_action("PLAY", "Player.PlayPause", NULL, NULL, 0, 1, 1, 0); 708 | register_action("PREVIOUS", "Player.GoPrevious", NULL, NULL, 0, 1, 1, 0); 709 | register_action("REPEAT", "Player.Repeat", "\"state\":\"%s\"", repeat_args, repeat_args_size - 1, 1, 1, 1); 710 | register_action("SHUFFLE", "Player.Shuffle", NULL, NULL, 0, 1, 1, 0); 711 | register_action("STOP", "Player.Stop", NULL, NULL, 0, 1, 1, 0); 712 | register_action("UNSHUFFLE", "Player.UnShuffle", NULL, NULL, 0, 1, 1, 0); 713 | break; 714 | 715 | default: 716 | /* Player actions */ 717 | register_action("MENU", "Input.ShowOSD", NULL, NULL, 0, 1, 0, 0); 718 | register_action("NEXT", "Player.GoTo", "\"to\":\"next\"", NULL, 0, 1, 1, 0); 719 | register_action("PAUSE", "Player.SetSpeed", "\"speed\":0", NULL, 0, 1, 1, 0); 720 | register_action("PLAY", "Player.SetSpeed", "\"speed\":1", NULL, 0, 1, 1, 0); 721 | register_action("PREVIOUS", "Player.GoTo", "\"to\":\"previous\"", NULL, 0, 1, 1, 0); 722 | register_action("REPEAT", "Player.SetRepeat", "\"repeat\":\"%s\"", repeat_args, repeat_args_size, 1, 1, 0); 723 | register_action("SHUFFLE", "Player.SetShuffle", "\"shuffle\":true", NULL, 0, 1, 1, 0); 724 | register_action("STOP", "Player.Stop", NULL, NULL, 0, 1, 1, 0); 725 | register_action("UNSHUFFLE", "Player.SetShuffle", "\"shuffle\":false", NULL, 0, 1, 1, 0); 726 | /* Window actions */ 727 | register_action("FAVORITES", "GUI.ActivateWindow", "\"window\":\"favourites\"", NULL, 0, 1, 0, 0); 728 | register_action("MUSIC", "GUI.ActivateWindow", "\"window\":\"music\"", NULL, 0, 1, 0, 0); 729 | register_action("PICTURES", "GUI.ActivateWindow", "\"window\":\"pictures\"", NULL, 0, 1, 0, 0); 730 | register_action("PROGRAMS", "GUI.ActivateWindow", "\"window\":\"programs\"", NULL, 0, 1, 0, 0); 731 | register_action("SETTINGS", "GUI.ActivateWindow", "\"window\":\"settings\"", NULL, 0, 1, 0, 0); 732 | register_action("T_V", "GUI.ActivateWindow", "\"window\":\"pvr\"", NULL, 0, 1, 0, 0); 733 | register_action("VIDEOS", "GUI.ActivateWindow", "\"window\":\"videos\"", NULL, 0, 1, 0, 0); 734 | register_action("WEATHER", "GUI.ActivateWindow", "\"window\":\"weather\"", NULL, 0, 1, 0, 0); 735 | /* Other actions */ 736 | register_action("CONTEXT", "Input.ContextMenu", NULL, NULL, 0, 1, 0, 0); 737 | break; 738 | 739 | } 740 | 741 | } 742 | 743 | void 744 | perform_actions(const char* hyp) 745 | { 746 | 747 | int i = 0; 748 | int j = 0; 749 | int k = 0; 750 | int ls = 0; 751 | int len; 752 | int matched = 0; 753 | int player_id = -3; 754 | action_t* action; 755 | action_t* action_queued; 756 | action_t* queue[MAX_ACTIONS]; 757 | char* action_string; 758 | char* response = NULL; 759 | char* argument_search; 760 | char* params_fmt; 761 | const char* param; 762 | int expect_arg = 0; 763 | 764 | /* Prepare action queue from words in hypothesis */ 765 | do 766 | { 767 | if (*(hyp + i) == ' ' || *(hyp + i) == '\0') 768 | { 769 | 770 | /* Extract single word */ 771 | len = i - ls + 1; 772 | action_string = malloc(len); 773 | assert(action_string); 774 | memset(action_string, 0, len); 775 | memcpy(action_string, hyp + ls, len - 1); 776 | 777 | /* Reset loop iterator and end flag */ 778 | k = 0; 779 | matched = 0; 780 | 781 | /* Check if we're not expecting an argument to last action */ 782 | if (!expect_arg) 783 | { 784 | while (k < actions_count && !matched) 785 | { 786 | /* Process next action */ 787 | action = actions[k]; 788 | /* Check if action word matches spoken word */ 789 | if (strcmp(action->word, action_string) == 0) 790 | { 791 | /* Cache player ID if current action needs it */ 792 | if (action->needs_player_id && player_id == -3) 793 | player_id = get_json_rpc_response_int("Player.GetActivePlayers", NULL, "playerid"); 794 | /* Ignore action if it requires a player ID and we don't have a player ID */ 795 | if ( (action->needs_player_id && player_id >= 0) || !action->needs_player_id ) 796 | { 797 | /* Is this a repeating action? */ 798 | if (action->repeats > 1) 799 | { 800 | /* Repeating action has to be preceded by a repeatable action */ 801 | if (j > 0 && in_array(action->req, action->req_size, queue[j-1]->word)) 802 | /* Set number of repeats for preceding action */ 803 | queue[j-1]->repeats = action->repeats; 804 | else if (j == 0) 805 | print_log(LOG_WARNING, "No action to repeat"); 806 | else 807 | print_log(LOG_WARNING, "Action %s is not repeatable", queue[j-1]->word); 808 | } 809 | else 810 | { 811 | 812 | /* Insert a copy of action into queue */ 813 | action_queued = malloc(sizeof(action_t)); 814 | assert(action_queued); 815 | memcpy(action_queued, action, sizeof(action_t)); 816 | action_queued->params = NULL; 817 | queue[j++] = action_queued; 818 | 819 | /* Fill player ID if action needs it */ 820 | if (action->needs_player_id) 821 | { 822 | /* Player ID can be max 1 char */ 823 | action_queued->params = malloc(strlen("\"playerid\":") + 2); 824 | assert(action_queued->params); 825 | sprintf(action_queued->params, "\"playerid\":%d", player_id); 826 | } 827 | 828 | /* Fill action params if needed */ 829 | if (action->params) 830 | { 831 | if (action->req_size > 0) 832 | expect_arg = 1; 833 | else 834 | append_param(&action_queued->params, action->params); 835 | } 836 | 837 | } 838 | } 839 | else 840 | { 841 | print_log(LOG_WARNING, "Player action %s ignored as there is no active player", action_string); 842 | } 843 | /* Stop searching for a matching action */ 844 | matched = 1; 845 | } 846 | k++; 847 | } 848 | if (k == actions_count && !matched) 849 | print_log(LOG_WARNING, "Unknown action \"%s\"", action_string); 850 | } 851 | else 852 | { 853 | 854 | argument_search = malloc(strlen(action_string) + 2); 855 | assert(argument_search); 856 | sprintf(argument_search, "%s:", action_string); 857 | 858 | /* Don't look for an action but rather for an argument to last action; 859 | if the argument is optional, ignore the last entry in argument table 860 | (required => search until [size]; not required => search until [size - 1]) */ 861 | while (k < action->req_size - (1 - action->needs_argument) && !matched) 862 | { 863 | /* If current word is a valid argument to last action... */ 864 | if (strstr(action->req[k], argument_search)) 865 | { 866 | /* Get param value for current word */ 867 | param = strchr(action->req[k], ':') + 1; 868 | /* Generate formatted param string */ 869 | params_fmt = malloc(strlen(action->params) + strlen(param) + 1); 870 | assert(params_fmt); 871 | sprintf(params_fmt, action->params, param); 872 | /* Add formatted param string to last action's params */ 873 | append_param(&queue[j-1]->params, params_fmt); 874 | /* Cleanup */ 875 | free(params_fmt); 876 | /* Stop searching for an argument */ 877 | matched = 1; 878 | } 879 | k++; 880 | } 881 | 882 | free(argument_search); 883 | 884 | /* If no valid argument was found, delete last action */ 885 | if (!matched) 886 | { 887 | print_log(LOG_WARNING, "%s is not a valid argument for %s - interpreting as action", action_string, queue[j-1]->word); 888 | free(queue[j-1]->params); 889 | free(queue[j-1]); 890 | j--; 891 | /* Current word is probably an action - process it again */ 892 | i -= strlen(action_string) + 1; 893 | } 894 | 895 | /* Don't expect an argument any more */ 896 | expect_arg = 0; 897 | 898 | } 899 | 900 | free(action_string); 901 | ls = i + 1; 902 | 903 | } 904 | } 905 | while (*(hyp + i++) != '\0' && j < MAX_ACTIONS); 906 | 907 | /* Check if the last command accepts an argument which was not given */ 908 | if (expect_arg) 909 | { 910 | /* If the command requires an argument, discard last action */ 911 | if (action->needs_argument) 912 | { 913 | print_log(LOG_WARNING, "Action %s requires an argument, none given - ignoring action", action->word); 914 | free(queue[j-1]->params); 915 | free(queue[j-1]); 916 | j--; 917 | } 918 | else 919 | /* If the command also works without an argument, process it with the default argument */ 920 | { 921 | /* Get param value for default action */ 922 | param = action->req[action->req_size-1]; 923 | /* Generate formatted param string */ 924 | params_fmt = malloc(strlen(action->params) + strlen(param) + 1); 925 | assert(params_fmt); 926 | sprintf(params_fmt, action->params, param); 927 | /* Add formatted param string to last action's params */ 928 | append_param(&queue[j-1]->params, params_fmt); 929 | /* Cleanup */ 930 | free(params_fmt); 931 | } 932 | } 933 | 934 | /* Execute all actions from queue */ 935 | for (i=0; irepeats; k++) 939 | { 940 | send_json_rpc_request(queue[i]->method, queue[i]->params, NULL); 941 | usleep(200000); 942 | } 943 | free(queue[i]->params); 944 | free(queue[i]); 945 | } 946 | 947 | /* Cleanup */ 948 | free(response); 949 | 950 | } 951 | 952 | void 953 | register_cmap(const char* string, const int character) 954 | { 955 | 956 | cmap_t* mapping = malloc(sizeof(cmap_t)); 957 | assert(mapping); 958 | mapping->string = malloc(strlen(string) + 1); 959 | strcpy(mapping->string, string); 960 | mapping->character = character; 961 | 962 | cmap = realloc(cmap, sizeof(cmap_t *) * (cmap_count + 1)); 963 | assert(cmap); 964 | cmap[cmap_count] = mapping; 965 | cmap_count++; 966 | 967 | } 968 | 969 | void 970 | initialize_cmap(void) 971 | { 972 | 973 | /* Letters */ 974 | register_cmap("ALPHA", 'a'); 975 | register_cmap("BRAVO", 'b'); 976 | register_cmap("CHARLIE", 'c'); 977 | register_cmap("DELTA", 'd'); 978 | register_cmap("ECHO", 'e'); 979 | register_cmap("FOXTROT", 'f'); 980 | register_cmap("GOLF", 'g'); 981 | register_cmap("HOTEL", 'h'); 982 | register_cmap("INDIA", 'i'); 983 | register_cmap("JULIET", 'j'); 984 | register_cmap("KILO", 'k'); 985 | register_cmap("LIMA", 'l'); 986 | register_cmap("MIKE", 'm'); 987 | register_cmap("NOVEMBER", 'n'); 988 | register_cmap("OSCAR", 'o'); 989 | register_cmap("PAPA", 'p'); 990 | register_cmap("QUEBEC", 'q'); 991 | register_cmap("ROMEO", 'r'); 992 | register_cmap("SIERRA", 's'); 993 | register_cmap("TANGO", 't'); 994 | register_cmap("UNIFORM", 'u'); 995 | register_cmap("VICTOR", 'v'); 996 | register_cmap("WHISKEY", 'w'); 997 | register_cmap("X_RAY", 'x'); 998 | register_cmap("YANKEE", 'y'); 999 | register_cmap("ZULU", 'z'); 1000 | 1001 | /* Digits */ 1002 | register_cmap("ZERO", '0'); 1003 | register_cmap("ONE", '1'); 1004 | register_cmap("TWO", '2'); 1005 | register_cmap("THREE", '3'); 1006 | register_cmap("FOUR", '4'); 1007 | register_cmap("FIVE", '5'); 1008 | register_cmap("SIX", '6'); 1009 | register_cmap("SEVEN", '7'); 1010 | register_cmap("EIGHT", '8'); 1011 | register_cmap("NINE", '9'); 1012 | 1013 | /* Punctuation */ 1014 | register_cmap("COLON", ':'); 1015 | register_cmap("COMMA", ','); 1016 | register_cmap("DOT", '.'); 1017 | register_cmap("HYPHEN", '-'); 1018 | register_cmap("SPACE", ' '); 1019 | 1020 | } 1021 | 1022 | int 1023 | find_cmap(const char* string) 1024 | { 1025 | 1026 | int found = 0; 1027 | int i = 0; 1028 | int retval = -1; 1029 | 1030 | while(i < cmap_count && !found) 1031 | { 1032 | if (strcmp(cmap[i]->string, string) == 0) 1033 | { 1034 | retval = cmap[i]->character; 1035 | found = 1; 1036 | } 1037 | i++; 1038 | } 1039 | 1040 | return retval; 1041 | 1042 | } 1043 | 1044 | void 1045 | perform_spelling(const char* hyp) 1046 | { 1047 | 1048 | int i = 0; 1049 | int j = strlen(spelling_buffer); 1050 | int ls = -1; 1051 | int character; 1052 | char* command; 1053 | 1054 | do 1055 | { 1056 | if (*(hyp + i) == ' ' || *(hyp + i) == '\0') 1057 | { 1058 | 1059 | /* If spelling buffer is full, end processing */ 1060 | if (j == SPELLING_BUFFER_SIZE - 1) 1061 | break; 1062 | 1063 | /* Extract a single command */ 1064 | command = malloc(i - ls); 1065 | assert(command); 1066 | memset(command, 0, i - ls); 1067 | memcpy(command, hyp + ls + 1, i - ls - 1); 1068 | 1069 | /* DELETE command is treated separately as it doesn't add characters to the buffer */ 1070 | if (strcmp("DELETE", command) == 0) 1071 | { 1072 | if (j > 0) 1073 | { 1074 | spelling_buffer[j - 1] = '\0'; 1075 | j--; 1076 | } 1077 | } 1078 | else if (strcmp("LOWER", command) == 0) 1079 | { 1080 | spelling_case = 0; 1081 | } 1082 | else if (strcmp("UPPER", command) == 0) 1083 | { 1084 | spelling_case = 1; 1085 | } 1086 | else 1087 | { 1088 | /* Try to find a character matching the command */ 1089 | character = find_cmap(command); 1090 | if (character != -1) 1091 | /* If the command is valid, append the character mapped to it to the buffer */ 1092 | spelling_buffer[j++] = spelling_case ? toupper(character) : character; 1093 | else if (strlen(command) > 0) 1094 | /* If the command is invalid, print out a warning */ 1095 | print_log(LOG_WARNING, "Unknown spelling mode command \"%s\"", command); 1096 | } 1097 | 1098 | ls = i; 1099 | free(command); 1100 | 1101 | } 1102 | } 1103 | while (*(hyp + i++) != '\0'); 1104 | 1105 | } 1106 | 1107 | int 1108 | process_hypothesis(const char* hyp) 1109 | { 1110 | 1111 | char* hyp_new = strdup(hyp); 1112 | char* next_word; 1113 | char* params; 1114 | int retval = 0; 1115 | 1116 | if (config_locking) 1117 | { 1118 | /* If we are locked and... */ 1119 | if (locked) 1120 | { 1121 | /* ...the first command heard is the unlock command, unlock and continue */ 1122 | if (strstr(hyp, COMMAND_UNLOCK) == hyp) 1123 | { 1124 | locked = 0; 1125 | print_log(LOG_INFO, "kodivc is now unlocked"); 1126 | /* Check if there are further commands after the unlock command */ 1127 | next_word = strchr(hyp, ' '); 1128 | if (next_word) 1129 | { 1130 | /* If yes, remove the unlock command from the hypothesis */ 1131 | free(hyp_new); 1132 | hyp_new = strdup(next_word + 1); 1133 | } 1134 | else 1135 | { 1136 | /* If not, send GUI notification confirming unlocking */ 1137 | params = malloc(strlen("Current mode: %s") + strlen(modes[mode])); 1138 | assert(params); 1139 | sprintf(params, "Current mode: %s", modes[mode]); 1140 | send_gui_notification("Voice recognition enabled", params, "warning"); 1141 | print_log(LOG_INFO, "Current mode: %s", modes[mode]); 1142 | free(params); 1143 | free(hyp_new); 1144 | hyp_new = strdup(""); 1145 | } 1146 | } 1147 | /* ...the first command heard is not the unlock command, warn and ignore all commands */ 1148 | else 1149 | { 1150 | print_log(LOG_WARNING, "kodivc is locked and not processing commands, say " COMMAND_UNLOCK " to unlock"); 1151 | } 1152 | } 1153 | /* If we are unlocked and the only command heard is the lock command, lock */ 1154 | else if (strcmp(COMMAND_LOCK, hyp_new) == 0) 1155 | { 1156 | locked = 1; 1157 | send_gui_notification("Voice recognition disabled", "Not listening for commands", "warning"); 1158 | print_log(LOG_INFO, "kodivc is now locked"); 1159 | } 1160 | } 1161 | 1162 | /* If we are unlocked or we don't care about locking... */ 1163 | if ((config_locking && !locked) || !config_locking) 1164 | { 1165 | /* Check for mode-changing keywords */ 1166 | switch(mode) 1167 | { 1168 | 1169 | case MODE_NORMAL: 1170 | /* Change to spelling mode */ 1171 | if (strcmp("SPELL", hyp_new) == 0) 1172 | { 1173 | if (kodi_version >= KODI_VERSION_FRODO) 1174 | { 1175 | memset(spelling_buffer, 0, SPELLING_BUFFER_SIZE); 1176 | send_json_rpc_request("Input.SendText", "\"text\":\"\",\"done\":false", NULL); 1177 | spelling_case = 0; 1178 | mode = MODE_SPELLING; 1179 | retval = 1; 1180 | print_log(LOG_INFO, "Changed to spelling mode"); 1181 | send_gui_notification("Voice recognition mode changed", "Current mode: spelling", "warning"); 1182 | } 1183 | else 1184 | { 1185 | print_log(LOG_ERR, "Spelling mode not available before Frodo"); 1186 | } 1187 | } 1188 | else if (strlen(hyp_new) > 0) 1189 | { 1190 | /* Send GUI notification with the commands heard */ 1191 | send_gui_notification("Voice command heard", hyp_new, "info"); 1192 | /* Perform requested actions */ 1193 | perform_actions(hyp_new); 1194 | } 1195 | break; 1196 | 1197 | case MODE_SPELLING: 1198 | /* Return to normal mode, accepting input */ 1199 | if (strcmp("ACCEPT", hyp_new) == 0) 1200 | { 1201 | send_json_rpc_request("Input.ExecuteAction", "\"action\":\"enter\"", NULL); 1202 | send_gui_notification("Voice recognition mode changed", "Current mode: normal", "warning"); 1203 | mode = MODE_NORMAL; 1204 | retval = 1; 1205 | print_log(LOG_INFO, "Changed to normal mode"); 1206 | } 1207 | /* Return to normal mode, rejecting input */ 1208 | else if (strcmp("CANCEL", hyp_new) == 0) 1209 | { 1210 | send_json_rpc_request("Input.ExecuteAction", "\"action\":\"previousmenu\"", NULL); 1211 | send_gui_notification("Voice recognition mode changed", "Current mode: normal", "warning"); 1212 | mode = MODE_NORMAL; 1213 | retval = 1; 1214 | print_log(LOG_INFO, "Changed to normal mode"); 1215 | } 1216 | /* Clear input */ 1217 | else if (strcmp("CLEAR", hyp_new) == 0) 1218 | { 1219 | memset(spelling_buffer, 0, SPELLING_BUFFER_SIZE); 1220 | send_json_rpc_request("Input.SendText", "\"text\":\"\",\"done\":false", NULL); 1221 | } 1222 | /* Return to normal mode */ 1223 | else if (strcmp("NORMAL", hyp_new) == 0) 1224 | { 1225 | /* Send GUI notification and change mode */ 1226 | send_gui_notification("Voice recognition mode changed", "Current mode: normal", "warning"); 1227 | mode = MODE_NORMAL; 1228 | retval = 1; 1229 | print_log(LOG_INFO, "Changed to normal mode"); 1230 | } 1231 | else 1232 | { 1233 | perform_spelling(hyp_new); 1234 | params = malloc(strlen("\"text\":\"%s\",\"done\":false") + strlen(spelling_buffer)); 1235 | assert(params); 1236 | sprintf(params, "\"text\":\"%s\",\"done\":false", spelling_buffer); 1237 | send_json_rpc_request("Input.SendText", params, NULL); 1238 | free(params); 1239 | } 1240 | break; 1241 | 1242 | } 1243 | } 1244 | 1245 | free(hyp_new); 1246 | 1247 | return retval; 1248 | 1249 | } 1250 | 1251 | int 1252 | main(int argc, char* argv[]) 1253 | { 1254 | 1255 | struct rlimit core_limit; 1256 | int pid; 1257 | int i; 1258 | char* dict; 1259 | char hyp_test[255]; 1260 | cmd_ln_t* config; 1261 | ps_decoder_t* ps; 1262 | ad_rec_t* ad; 1263 | cont_ad_t* cont; 1264 | int16 adbuf[4096]; 1265 | int32 k; 1266 | int32 timestamp; 1267 | int32 result; 1268 | const char* hyp; 1269 | 1270 | /* Enable core dumps */ 1271 | core_limit.rlim_cur = RLIM_INFINITY; 1272 | core_limit.rlim_max = RLIM_INFINITY; 1273 | setrlimit(RLIMIT_CORE, &core_limit); 1274 | 1275 | /* Register a memory-freeing routine to run upon exiting */ 1276 | assert(atexit(cleanup) == 0); 1277 | 1278 | /* Parse command line options */ 1279 | parse_options(argc, argv); 1280 | 1281 | if (config_daemon) 1282 | { 1283 | 1284 | /* Fork */ 1285 | pid = fork(); 1286 | /* Fork failed */ 1287 | if (pid == -1) 1288 | die("Unable to fork"); 1289 | /* We're in the parent process - exit */ 1290 | else if (pid > 0) 1291 | exit(0); 1292 | 1293 | /* From now on, we're in the child process - daemonize */ 1294 | umask(0); 1295 | if (setsid() == -1) 1296 | die("Unable to create a new session for child process"); 1297 | if (chdir("/tmp") == -1) 1298 | die("Unable to change directory to /tmp"); 1299 | if (freopen("/dev/null", "r", stdin) == NULL) 1300 | die("Failed to redirect stdin"); 1301 | if (freopen("/dev/null", "w", stdout) == NULL) 1302 | die("Failed to redirect stdout"); 1303 | if (freopen("/dev/null", "w", stderr) == NULL) 1304 | die("Failed to redirect stderr"); 1305 | 1306 | } 1307 | 1308 | /* Check if language model files were properly installed */ 1309 | if (access(MODEL_HMM, R_OK) == -1) 1310 | die("Hidden Markov acoustic model not found at %s. Please check your Pocketsphinx installation.", MODEL_HMM); 1311 | 1312 | if (access(MODEL_LM, R_OK) == -1) 1313 | die("kodivc language model not found at %s. Please check your Pocketsphinx installation.", MODEL_LM); 1314 | 1315 | for (i=0; i KODI_VERSION_MAX) 1337 | print_log(LOG_WARNING, "Support for Kodi version %d, which is running at %s:%s, is EXPERIMENTAL", kodi_version, config_json_rpc_host, config_json_rpc_port); 1338 | 1339 | /* Setup action database */ 1340 | initialize_actions(); 1341 | /* Setup command to character mapping database */ 1342 | initialize_cmap(); 1343 | 1344 | if (config_test_mode) 1345 | { 1346 | print_log(LOG_INFO, "Test mode enabled - enter space-separated commands in ALL CAPS. Enter blank line to end."); 1347 | for (;;) 1348 | { 1349 | if (fgets(hyp_test, 255, stdin) == NULL || hyp_test[0] == '\n') 1350 | { 1351 | break; 1352 | } 1353 | else 1354 | { 1355 | /* Trim newline from hypothesis */ 1356 | *(hyp_test + strlen(hyp_test) - 1) = '\0'; 1357 | /* Log */ 1358 | print_log(LOG_INFO, "Line read: \"%s\"", hyp_test); 1359 | /* Process hypothesis */ 1360 | process_hypothesis(hyp_test); 1361 | } 1362 | } 1363 | print_log(LOG_INFO, "Blank line read, exiting"); 1364 | } 1365 | else 1366 | { 1367 | 1368 | /* Suppress verbose messages from pocketsphinx */ 1369 | if (freopen("/dev/null", "w", stderr) == NULL) 1370 | die("Failed to redirect stderr"); 1371 | 1372 | /* Initialize pocketsphinx */ 1373 | config = cmd_ln_init(NULL, ps_args(), TRUE, 1374 | "-hmm", MODEL_HMM, 1375 | "-lm", MODEL_LM, 1376 | "-dict", MODEL_DICT, 1377 | NULL); 1378 | if (config == NULL) 1379 | die("Error creating pocketsphinx configuration"); 1380 | 1381 | ps = ps_init(config); 1382 | if (ps == NULL) 1383 | die("Error initializing pocketsphinx"); 1384 | 1385 | /* Open audio device for recording */ 1386 | if ((ad = ad_open_dev(config_audio_device, 16000)) == NULL) 1387 | die("Failed to open audio device"); 1388 | /* Initialize continous listening module */ 1389 | if ((cont = cont_ad_init(ad, ad_read)) == NULL) 1390 | die("Failed to initialize voice activity detection"); 1391 | /* Start recording */ 1392 | if (ad_start_rec(ad) < 0) 1393 | die("Failed to start recording"); 1394 | /* Calibrate voice detection */ 1395 | if (cont_ad_calib(cont) < 0) 1396 | die("Failed to calibrate voice activity detection"); 1397 | 1398 | /* Intercept SIGINT and SIGTERM for proper cleanup */ 1399 | signal(SIGINT, set_exit_flag); 1400 | signal(SIGTERM, set_exit_flag); 1401 | 1402 | print_log(LOG_INFO, "Ready for listening!"); 1403 | 1404 | /* Main listening loop */ 1405 | for (;;) 1406 | { 1407 | 1408 | /* Wait until we get any samples */ 1409 | while ((k = cont_ad_read(cont, adbuf, 4096)) == 0) 1410 | { 1411 | if (usleep(100000) == -1) 1412 | break; 1413 | } 1414 | 1415 | /* Exit main loop if we were interrupted */ 1416 | if (exit_flag) 1417 | break; 1418 | 1419 | if (k < 0) 1420 | die("Failed to read audio"); 1421 | 1422 | /* Start collecting utterance data */ 1423 | if (ps_start_utt(ps, NULL) < 0) 1424 | die("Failed to start utterance"); 1425 | 1426 | if ((result = ps_process_raw(ps, adbuf, k, FALSE, FALSE)) < 0) 1427 | die("Failed to process utterance data"); 1428 | 1429 | /* Save timestamp for initial utterance samples */ 1430 | timestamp = cont->read_ts; 1431 | 1432 | /* Read the rest of utterance */ 1433 | for (;;) 1434 | { 1435 | 1436 | if ((k = cont_ad_read(cont, adbuf, 4096)) < 0) 1437 | die("Failed to read audio"); 1438 | 1439 | if (k == 0) 1440 | { 1441 | /* Has it been 500ms since we last read any samples? */ 1442 | if ((cont->read_ts - timestamp) > DEFAULT_SAMPLES_PER_SEC/8) 1443 | /* YES - Break the listening loop */ 1444 | break; 1445 | else 1446 | /* NO - Wait a bit before reading further data */ 1447 | if (usleep(20000) == -1) 1448 | break; 1449 | } 1450 | else 1451 | { 1452 | /* New samples received - update timestamp */ 1453 | timestamp = cont->read_ts; 1454 | /* Process the samples received */ 1455 | result = ps_process_raw(ps, adbuf, k, FALSE, FALSE); 1456 | } 1457 | 1458 | } 1459 | 1460 | /* Stop listening */ 1461 | ad_stop_rec(ad); 1462 | /* Flush any samples remaining in buffer - they will not be processed */ 1463 | while (ad_read(ad, adbuf, 4096) >= 0); 1464 | /* Reset continous listening module */ 1465 | cont_ad_reset(cont); 1466 | /* End utterance */ 1467 | ps_end_utt(ps); 1468 | 1469 | /* Exit main loop if we were interrupted */ 1470 | if (exit_flag) 1471 | break; 1472 | 1473 | /* Get hypothesis for utterance */ 1474 | hyp = ps_get_hyp(ps, NULL, NULL); 1475 | /* Print hypothesis */ 1476 | print_log(LOG_INFO, "Heard: \"%s\"", hyp); 1477 | /* Process hypothesis */ 1478 | if (process_hypothesis(hyp) == 1) 1479 | { 1480 | /* If process_hypothesis() returns 1, mode of operation has changed - load a proper dictionary */ 1481 | dict = malloc(strlen(MODELDIR "/lm/en/kodivc/.dic") + strlen(modes[mode]) + 1); 1482 | assert(dict); 1483 | sprintf(dict, MODELDIR "/lm/en/kodivc/%s.dic", modes[mode]); 1484 | ps_load_dict(ps, dict, NULL, NULL); 1485 | free(dict); 1486 | } 1487 | 1488 | /* Resume recording */ 1489 | if (ad_start_rec(ad) < 0) 1490 | die("Failed to start recording"); 1491 | 1492 | } 1493 | 1494 | print_log(LOG_INFO, "Signal caught - exiting"); 1495 | 1496 | /* Cleanup */ 1497 | cont_ad_close(cont); 1498 | ad_close(ad); 1499 | ps_free(ps); 1500 | 1501 | } 1502 | 1503 | return 0; 1504 | 1505 | } 1506 | 1507 | -------------------------------------------------------------------------------- /model/kodivc.lm: -------------------------------------------------------------------------------- 1 | Language model created by QuickLM on Thu Jan 8 05:15:29 EST 2015 2 | Copyright (c) 1996-2010 Carnegie Mellon University and Alexander I. Rudnicky 3 | 4 | The model is in standard ARPA format, designed by Doug Paul while he was at MITRE. 5 | 6 | The code that was used to produce this language model is available in Open Source. 7 | Please visit http://www.speech.cs.cmu.edu/tools/ for more information 8 | 9 | The (fixed) discount mass is 0.5. The backoffs are computed using the ratio method. 10 | This model based on a corpus of 91 sentences and 93 words 11 | 12 | \data\ 13 | ngram 1=93 14 | ngram 2=182 15 | ngram 3=91 16 | 17 | \1-grams: 18 | -0.7782 -0.3010 19 | -0.7782 -0.2218 20 | -2.7372 ACCEPT -0.2218 21 | -2.7372 ALL -0.2218 22 | -2.7372 ALPHA -0.2218 23 | -2.7372 BACK -0.2218 24 | -2.7372 BRAVO -0.2218 25 | -2.7372 CANCEL -0.2218 26 | -2.7372 CHARLIE -0.2218 27 | -2.7372 CLEAR -0.2218 28 | -2.7372 COLON -0.2218 29 | -2.7372 COMMA -0.2218 30 | -2.7372 CONTEXT -0.2218 31 | -2.7372 DELETE -0.2218 32 | -2.7372 DELTA -0.2218 33 | -2.7372 DOT -0.2218 34 | -2.7372 DOWNWARDS -0.2218 35 | -2.7372 ECHO -0.2218 36 | -2.7372 EIGHT -0.2218 37 | -2.7372 EIGHTY -0.2218 38 | -2.7372 FAVORITES -0.2218 39 | -2.7372 FIFTY -0.2218 40 | -2.7372 FIVE -0.2218 41 | -2.7372 FORTY -0.2218 42 | -2.7372 FOUR -0.2218 43 | -2.7372 FOXTROT -0.2218 44 | -2.7372 GOLF -0.2218 45 | -2.7372 HOME -0.2218 46 | -2.7372 HOTEL -0.2218 47 | -2.7372 HYPHEN -0.2218 48 | -2.7372 INDIA -0.2218 49 | -2.7372 JULIET -0.2218 50 | -2.7372 KILO -0.2218 51 | -2.7372 KODI -0.2218 52 | -2.7372 LEFT -0.2218 53 | -2.7372 LIMA -0.2218 54 | -2.7372 LOWER -0.2218 55 | -2.7372 MAX -0.2218 56 | -2.7372 MENU -0.2218 57 | -2.7372 MIKE -0.2218 58 | -2.7372 MUSIC -0.2218 59 | -2.7372 MUTE -0.2218 60 | -2.7372 NEXT -0.2218 61 | -2.7372 NINE -0.2218 62 | -2.7372 NINETY -0.2218 63 | -2.7372 NORMAL -0.2218 64 | -2.7372 NOVEMBER -0.2218 65 | -2.7372 OFF -0.2218 66 | -2.7372 OKAY -0.2218 67 | -2.7372 ONE -0.2218 68 | -2.7372 OSCAR -0.2218 69 | -2.7372 PAPA -0.2218 70 | -2.7372 PAUSE -0.2218 71 | -2.7372 PICTURES -0.2218 72 | -2.7372 PLAY -0.2218 73 | -2.7372 PREVIOUS -0.2218 74 | -2.7372 PROGRAMS -0.2218 75 | -2.7372 QUEBEC -0.2218 76 | -2.7372 REPEAT -0.2218 77 | -2.7372 RIGHT -0.2218 78 | -2.7372 ROMEO -0.2218 79 | -2.7372 SELECT -0.2218 80 | -2.7372 SETTINGS -0.2218 81 | -2.7372 SEVEN -0.2218 82 | -2.7372 SEVENTY -0.2218 83 | -2.7372 SHUFFLE -0.2218 84 | -2.7372 SIERRA -0.2218 85 | -2.7372 SIX -0.2218 86 | -2.7372 SIXTY -0.2218 87 | -2.7372 SPACE -0.2218 88 | -2.7372 SPELL -0.2218 89 | -2.7372 STOP -0.2218 90 | -2.7372 TANGO -0.2218 91 | -2.7372 TEN -0.2218 92 | -2.7372 THIRTY -0.2218 93 | -2.7372 THREE -0.2218 94 | -2.7372 TWENTY -0.2218 95 | -2.7372 TWO -0.2218 96 | -2.7372 T_V -0.2218 97 | -2.7372 UNIFORM -0.2218 98 | -2.7372 UNMUTE -0.2218 99 | -2.7372 UNSHUFFLE -0.2218 100 | -2.7372 UPPER -0.2218 101 | -2.7372 UPWARDS -0.2218 102 | -2.7372 VICTOR -0.2218 103 | -2.7372 VIDEOS -0.2218 104 | -2.7372 VOLUME -0.2218 105 | -2.7372 WEATHER -0.2218 106 | -2.7372 WHISKEY -0.2218 107 | -2.7372 X_RAY -0.2218 108 | -2.7372 YANKEE -0.2218 109 | -2.7372 ZERO -0.2218 110 | -2.7372 ZULU -0.2218 111 | 112 | \2-grams: 113 | -2.2601 ACCEPT 0.0000 114 | -2.2601 ALL 0.0000 115 | -2.2601 ALPHA 0.0000 116 | -2.2601 BACK 0.0000 117 | -2.2601 BRAVO 0.0000 118 | -2.2601 CANCEL 0.0000 119 | -2.2601 CHARLIE 0.0000 120 | -2.2601 CLEAR 0.0000 121 | -2.2601 COLON 0.0000 122 | -2.2601 COMMA 0.0000 123 | -2.2601 CONTEXT 0.0000 124 | -2.2601 DELETE 0.0000 125 | -2.2601 DELTA 0.0000 126 | -2.2601 DOT 0.0000 127 | -2.2601 DOWNWARDS 0.0000 128 | -2.2601 ECHO 0.0000 129 | -2.2601 EIGHT 0.0000 130 | -2.2601 EIGHTY 0.0000 131 | -2.2601 FAVORITES 0.0000 132 | -2.2601 FIFTY 0.0000 133 | -2.2601 FIVE 0.0000 134 | -2.2601 FORTY 0.0000 135 | -2.2601 FOUR 0.0000 136 | -2.2601 FOXTROT 0.0000 137 | -2.2601 GOLF 0.0000 138 | -2.2601 HOME 0.0000 139 | -2.2601 HOTEL 0.0000 140 | -2.2601 HYPHEN 0.0000 141 | -2.2601 INDIA 0.0000 142 | -2.2601 JULIET 0.0000 143 | -2.2601 KILO 0.0000 144 | -2.2601 KODI 0.0000 145 | -2.2601 LEFT 0.0000 146 | -2.2601 LIMA 0.0000 147 | -2.2601 LOWER 0.0000 148 | -2.2601 MAX 0.0000 149 | -2.2601 MENU 0.0000 150 | -2.2601 MIKE 0.0000 151 | -2.2601 MUSIC 0.0000 152 | -2.2601 MUTE 0.0000 153 | -2.2601 NEXT 0.0000 154 | -2.2601 NINE 0.0000 155 | -2.2601 NINETY 0.0000 156 | -2.2601 NORMAL 0.0000 157 | -2.2601 NOVEMBER 0.0000 158 | -2.2601 OFF 0.0000 159 | -2.2601 OKAY 0.0000 160 | -2.2601 ONE 0.0000 161 | -2.2601 OSCAR 0.0000 162 | -2.2601 PAPA 0.0000 163 | -2.2601 PAUSE 0.0000 164 | -2.2601 PICTURES 0.0000 165 | -2.2601 PLAY 0.0000 166 | -2.2601 PREVIOUS 0.0000 167 | -2.2601 PROGRAMS 0.0000 168 | -2.2601 QUEBEC 0.0000 169 | -2.2601 REPEAT 0.0000 170 | -2.2601 RIGHT 0.0000 171 | -2.2601 ROMEO 0.0000 172 | -2.2601 SELECT 0.0000 173 | -2.2601 SETTINGS 0.0000 174 | -2.2601 SEVEN 0.0000 175 | -2.2601 SEVENTY 0.0000 176 | -2.2601 SHUFFLE 0.0000 177 | -2.2601 SIERRA 0.0000 178 | -2.2601 SIX 0.0000 179 | -2.2601 SIXTY 0.0000 180 | -2.2601 SPACE 0.0000 181 | -2.2601 SPELL 0.0000 182 | -2.2601 STOP 0.0000 183 | -2.2601 TANGO 0.0000 184 | -2.2601 TEN 0.0000 185 | -2.2601 THIRTY 0.0000 186 | -2.2601 THREE 0.0000 187 | -2.2601 TWENTY 0.0000 188 | -2.2601 TWO 0.0000 189 | -2.2601 T_V 0.0000 190 | -2.2601 UNIFORM 0.0000 191 | -2.2601 UNMUTE 0.0000 192 | -2.2601 UNSHUFFLE 0.0000 193 | -2.2601 UPPER 0.0000 194 | -2.2601 UPWARDS 0.0000 195 | -2.2601 VICTOR 0.0000 196 | -2.2601 VIDEOS 0.0000 197 | -2.2601 VOLUME 0.0000 198 | -2.2601 WEATHER 0.0000 199 | -2.2601 WHISKEY 0.0000 200 | -2.2601 X_RAY 0.0000 201 | -2.2601 YANKEE 0.0000 202 | -2.2601 ZERO 0.0000 203 | -2.2601 ZULU 0.0000 204 | -0.3010 ACCEPT -0.3010 205 | -0.3010 ALL -0.3010 206 | -0.3010 ALPHA -0.3010 207 | -0.3010 BACK -0.3010 208 | -0.3010 BRAVO -0.3010 209 | -0.3010 CANCEL -0.3010 210 | -0.3010 CHARLIE -0.3010 211 | -0.3010 CLEAR -0.3010 212 | -0.3010 COLON -0.3010 213 | -0.3010 COMMA -0.3010 214 | -0.3010 CONTEXT -0.3010 215 | -0.3010 DELETE -0.3010 216 | -0.3010 DELTA -0.3010 217 | -0.3010 DOT -0.3010 218 | -0.3010 DOWNWARDS -0.3010 219 | -0.3010 ECHO -0.3010 220 | -0.3010 EIGHT -0.3010 221 | -0.3010 EIGHTY -0.3010 222 | -0.3010 FAVORITES -0.3010 223 | -0.3010 FIFTY -0.3010 224 | -0.3010 FIVE -0.3010 225 | -0.3010 FORTY -0.3010 226 | -0.3010 FOUR -0.3010 227 | -0.3010 FOXTROT -0.3010 228 | -0.3010 GOLF -0.3010 229 | -0.3010 HOME -0.3010 230 | -0.3010 HOTEL -0.3010 231 | -0.3010 HYPHEN -0.3010 232 | -0.3010 INDIA -0.3010 233 | -0.3010 JULIET -0.3010 234 | -0.3010 KILO -0.3010 235 | -0.3010 KODI -0.3010 236 | -0.3010 LEFT -0.3010 237 | -0.3010 LIMA -0.3010 238 | -0.3010 LOWER -0.3010 239 | -0.3010 MAX -0.3010 240 | -0.3010 MENU -0.3010 241 | -0.3010 MIKE -0.3010 242 | -0.3010 MUSIC -0.3010 243 | -0.3010 MUTE -0.3010 244 | -0.3010 NEXT -0.3010 245 | -0.3010 NINE -0.3010 246 | -0.3010 NINETY -0.3010 247 | -0.3010 NORMAL -0.3010 248 | -0.3010 NOVEMBER -0.3010 249 | -0.3010 OFF -0.3010 250 | -0.3010 OKAY -0.3010 251 | -0.3010 ONE -0.3010 252 | -0.3010 OSCAR -0.3010 253 | -0.3010 PAPA -0.3010 254 | -0.3010 PAUSE -0.3010 255 | -0.3010 PICTURES -0.3010 256 | -0.3010 PLAY -0.3010 257 | -0.3010 PREVIOUS -0.3010 258 | -0.3010 PROGRAMS -0.3010 259 | -0.3010 QUEBEC -0.3010 260 | -0.3010 REPEAT -0.3010 261 | -0.3010 RIGHT -0.3010 262 | -0.3010 ROMEO -0.3010 263 | -0.3010 SELECT -0.3010 264 | -0.3010 SETTINGS -0.3010 265 | -0.3010 SEVEN -0.3010 266 | -0.3010 SEVENTY -0.3010 267 | -0.3010 SHUFFLE -0.3010 268 | -0.3010 SIERRA -0.3010 269 | -0.3010 SIX -0.3010 270 | -0.3010 SIXTY -0.3010 271 | -0.3010 SPACE -0.3010 272 | -0.3010 SPELL -0.3010 273 | -0.3010 STOP -0.3010 274 | -0.3010 TANGO -0.3010 275 | -0.3010 TEN -0.3010 276 | -0.3010 THIRTY -0.3010 277 | -0.3010 THREE -0.3010 278 | -0.3010 TWENTY -0.3010 279 | -0.3010 TWO -0.3010 280 | -0.3010 T_V -0.3010 281 | -0.3010 UNIFORM -0.3010 282 | -0.3010 UNMUTE -0.3010 283 | -0.3010 UNSHUFFLE -0.3010 284 | -0.3010 UPPER -0.3010 285 | -0.3010 UPWARDS -0.3010 286 | -0.3010 VICTOR -0.3010 287 | -0.3010 VIDEOS -0.3010 288 | -0.3010 VOLUME -0.3010 289 | -0.3010 WEATHER -0.3010 290 | -0.3010 WHISKEY -0.3010 291 | -0.3010 X_RAY -0.3010 292 | -0.3010 YANKEE -0.3010 293 | -0.3010 ZERO -0.3010 294 | -0.3010 ZULU -0.3010 295 | 296 | \3-grams: 297 | -0.3010 ACCEPT 298 | -0.3010 ALL 299 | -0.3010 ALPHA 300 | -0.3010 BACK 301 | -0.3010 BRAVO 302 | -0.3010 CANCEL 303 | -0.3010 CHARLIE 304 | -0.3010 CLEAR 305 | -0.3010 COLON 306 | -0.3010 COMMA 307 | -0.3010 CONTEXT 308 | -0.3010 DELETE 309 | -0.3010 DELTA 310 | -0.3010 DOT 311 | -0.3010 DOWNWARDS 312 | -0.3010 ECHO 313 | -0.3010 EIGHT 314 | -0.3010 EIGHTY 315 | -0.3010 FAVORITES 316 | -0.3010 FIFTY 317 | -0.3010 FIVE 318 | -0.3010 FORTY 319 | -0.3010 FOUR 320 | -0.3010 FOXTROT 321 | -0.3010 GOLF 322 | -0.3010 HOME 323 | -0.3010 HOTEL 324 | -0.3010 HYPHEN 325 | -0.3010 INDIA 326 | -0.3010 JULIET 327 | -0.3010 KILO 328 | -0.3010 KODI 329 | -0.3010 LEFT 330 | -0.3010 LIMA 331 | -0.3010 LOWER 332 | -0.3010 MAX 333 | -0.3010 MENU 334 | -0.3010 MIKE 335 | -0.3010 MUSIC 336 | -0.3010 MUTE 337 | -0.3010 NEXT 338 | -0.3010 NINE 339 | -0.3010 NINETY 340 | -0.3010 NORMAL 341 | -0.3010 NOVEMBER 342 | -0.3010 OFF 343 | -0.3010 OKAY 344 | -0.3010 ONE 345 | -0.3010 OSCAR 346 | -0.3010 PAPA 347 | -0.3010 PAUSE 348 | -0.3010 PICTURES 349 | -0.3010 PLAY 350 | -0.3010 PREVIOUS 351 | -0.3010 PROGRAMS 352 | -0.3010 QUEBEC 353 | -0.3010 REPEAT 354 | -0.3010 RIGHT 355 | -0.3010 ROMEO 356 | -0.3010 SELECT 357 | -0.3010 SETTINGS 358 | -0.3010 SEVEN 359 | -0.3010 SEVENTY 360 | -0.3010 SHUFFLE 361 | -0.3010 SIERRA 362 | -0.3010 SIX 363 | -0.3010 SIXTY 364 | -0.3010 SPACE 365 | -0.3010 SPELL 366 | -0.3010 STOP 367 | -0.3010 TANGO 368 | -0.3010 TEN 369 | -0.3010 THIRTY 370 | -0.3010 THREE 371 | -0.3010 TWENTY 372 | -0.3010 TWO 373 | -0.3010 T_V 374 | -0.3010 UNIFORM 375 | -0.3010 UNMUTE 376 | -0.3010 UNSHUFFLE 377 | -0.3010 UPPER 378 | -0.3010 UPWARDS 379 | -0.3010 VICTOR 380 | -0.3010 VIDEOS 381 | -0.3010 VOLUME 382 | -0.3010 WEATHER 383 | -0.3010 WHISKEY 384 | -0.3010 X_RAY 385 | -0.3010 YANKEE 386 | -0.3010 ZERO 387 | -0.3010 ZULU 388 | 389 | \end\ 390 | -------------------------------------------------------------------------------- /model/kodivc.vocab: -------------------------------------------------------------------------------- 1 | #normal 2 | ALL 3 | BACK 4 | CONTEXT 5 | DOWNWARDS 6 | EIGHTY 7 | FAVORITES 8 | FIFTY 9 | FIVE 10 | FORTY 11 | FOUR 12 | HOME 13 | KODI 14 | LEFT 15 | MAX 16 | MENU 17 | MUSIC 18 | MUTE 19 | NEXT 20 | NINETY 21 | OFF 22 | OKAY 23 | ONE 24 | PAUSE 25 | PICTURES 26 | PLAY 27 | PREVIOUS 28 | PROGRAMS 29 | REPEAT 30 | RIGHT 31 | SELECT 32 | SETTINGS 33 | SEVENTY 34 | SHUFFLE 35 | SIXTY 36 | SPELL 37 | STOP 38 | TEN 39 | THIRTY 40 | THREE 41 | TWENTY 42 | TWO 43 | T_V 44 | UNMUTE 45 | UNSHUFFLE 46 | UPWARDS 47 | VIDEOS 48 | VOLUME 49 | WEATHER 50 | 51 | #spelling 52 | ACCEPT 53 | ALPHA 54 | BRAVO 55 | CANCEL 56 | CHARLIE 57 | CLEAR 58 | COLON 59 | COMMA 60 | DELETE 61 | DELTA 62 | DOT 63 | ECHO 64 | EIGHT 65 | FIVE 66 | FOUR 67 | FOXTROT 68 | GOLF 69 | HOTEL 70 | HYPHEN 71 | INDIA 72 | JULIET 73 | KILO 74 | KODI 75 | LIMA 76 | LOWER 77 | MIKE 78 | NINE 79 | NORMAL 80 | NOVEMBER 81 | OKAY 82 | ONE 83 | OSCAR 84 | PAPA 85 | QUEBEC 86 | ROMEO 87 | SEVEN 88 | SIERRA 89 | SIX 90 | SPACE 91 | TANGO 92 | THREE 93 | TWO 94 | UPPER 95 | UNIFORM 96 | VICTOR 97 | WHISKEY 98 | X_RAY 99 | YANKEE 100 | ZERO 101 | ZULU 102 | 103 | -------------------------------------------------------------------------------- /model/normal.dic: -------------------------------------------------------------------------------- 1 | ALL AO L 2 | BACK B AE K 3 | CONTEXT K AA N T EH K S T 4 | DOWNWARDS D AW N W ER D Z 5 | EIGHTY EY T IY 6 | FAVORITES F EY V ER IH T S 7 | FAVORITES(2) F EY V R AH T S 8 | FIFTY F IH F T IY 9 | FIVE F AY V 10 | FORTY F AO R T IY 11 | FOUR F AO R 12 | HOME HH OW M 13 | KODI K OW D IY 14 | LEFT L EH F T 15 | MAX M AE K S 16 | MENU M EH N Y UW 17 | MUSIC M Y UW Z IH K 18 | MUTE M Y UW T 19 | NEXT N EH K S T 20 | NEXT(2) N EH K S 21 | NINETY N AY N T IY 22 | OFF AO F 23 | OKAY OW K EY 24 | ONE W AH N 25 | ONE(2) HH W AH N 26 | PAUSE P AO Z 27 | PICTURES P IH K CH ER Z 28 | PLAY P L EY 29 | PREVIOUS P R IY V IY AH S 30 | PROGRAMS P R OW G R AE M Z 31 | REPEAT R IH P IY T 32 | REPEAT(2) R IY P IY T 33 | RIGHT R AY T 34 | SELECT S AH L EH K T 35 | SETTINGS S EH T IH NG Z 36 | SEVENTY S EH V AH N T IY 37 | SEVENTY(2) S EH V AH N IY 38 | SHUFFLE SH AH F AH L 39 | SIXTY S IH K S T IY 40 | SPELL S P EH L 41 | STOP S T AA P 42 | TEN T EH N 43 | THIRTY TH ER D IY 44 | THIRTY(2) TH ER T IY 45 | THREE TH R IY 46 | TWENTY T W EH N T IY 47 | TWENTY(2) T W EH N IY 48 | TWO T UW 49 | T_V T IY V IY 50 | UNMUTE AH N M Y UW T 51 | UNSHUFFLE AH N SH AH F AH L 52 | UPWARDS AH P W ER D Z 53 | VIDEOS V IH D IY OW Z 54 | VOLUME V AA L Y UW M 55 | WEATHER W EH DH ER 56 | -------------------------------------------------------------------------------- /model/spelling.dic: -------------------------------------------------------------------------------- 1 | ACCEPT AE K S EH P T 2 | ACCEPT(2) AH K S EH P T 3 | ALPHA AE L F AH 4 | BRAVO B R AA V OW 5 | CANCEL K AE N S AH L 6 | CHARLIE CH AA R L IY 7 | CLEAR K L IH R 8 | COLON K OW L AH N 9 | COMMA K AA M AH 10 | DELETE D IH L IY T 11 | DELTA D EH L T AH 12 | DOT D AA T 13 | ECHO EH K OW 14 | EIGHT EY T 15 | FIVE F AY V 16 | FOUR F AO R 17 | FOXTROT F AA K S T R AA T 18 | GOLF G AA L F 19 | GOLF(2) G AO L F 20 | HOTEL HH OW T EH L 21 | HYPHEN HH AY F AH N 22 | INDIA IH N D IY AH 23 | JULIET JH UW L IY EH T 24 | KILO K IH L OW 25 | KODI K OW D IY 26 | LIMA L AY M AH 27 | LIMA(2) L IY M AH 28 | LOWER L OW ER 29 | MIKE M AY K 30 | NINE N AY N 31 | NORMAL N AO R M AH L 32 | NOVEMBER N OW V EH M B ER 33 | OKAY OW K EY 34 | ONE W AH N 35 | ONE(2) HH W AH N 36 | OSCAR AO S K ER 37 | PAPA P AA P AH 38 | QUEBEC K W AH B EH K 39 | ROMEO R OW M IY OW 40 | SEVEN S EH V AH N 41 | SIERRA S IY EH R AH 42 | SIX S IH K S 43 | SPACE S P EY S 44 | TANGO T AE NG G OW 45 | THREE TH R IY 46 | TWO T UW 47 | UPPER AH P ER 48 | UNIFORM Y UW N AH F AO R M 49 | VICTOR V IH K T ER 50 | WHISKEY W IH S K IY 51 | WHISKEY(2) HH W IH S K IY 52 | X_RAY EH K S R EY 53 | YANKEE Y AE NG K IY 54 | ZERO Z IH R OW 55 | ZERO(2) Z IY R OW 56 | ZULU Z UW L UW 57 | --------------------------------------------------------------------------------