Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Picollm v1.2 #25

Merged
merged 5 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,6 @@ dependencies {
implementation 'ai.picovoice:android-voice-processor:1.0.2'
implementation 'ai.picovoice:porcupine-android:3.0.1'
implementation 'ai.picovoice:cheetah-android:2.0.0'
implementation 'ai.picovoice:picollm-android:1.1.0'
implementation 'ai.picovoice:picollm-android:1.2.0'
implementation 'ai.picovoice:orca-android:1.0.0'
}
2 changes: 1 addition & 1 deletion recipes/llm-voice-assistant/ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ platform :ios, '16.0'
target 'LLMVoiceAssistantDemo' do
pod 'Porcupine-iOS', '~> 3.0.1'
pod 'Cheetah-iOS', '~> 2.0.0'
pod 'picoLLM-iOS', '~> 1.1.0'
pod 'picoLLM-iOS', '~> 1.2.0'
pod 'Orca-iOS', '~> 1.0.0'
pod 'ios-voice-processor', '~> 1.1.0'
end
18 changes: 9 additions & 9 deletions recipes/llm-voice-assistant/ios/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
PODS:
- Cheetah-iOS (2.0.0)
- ios-voice-processor (1.1.0)
- ios-voice-processor (1.1.2)
- Orca-iOS (1.0.0)
- picoLLM-iOS (1.1.0)
- Porcupine-iOS (3.0.1):
- ios-voice-processor (~> 1.1.0)
- picoLLM-iOS (1.2.0)
- Porcupine-iOS (3.0.2):
- ios-voice-processor (~> 1.1.1)

DEPENDENCIES:
- Cheetah-iOS (~> 2.0.0)
- ios-voice-processor (~> 1.1.0)
- Orca-iOS (~> 1.0.0)
- picoLLM-iOS (~> 1.1.0)
- picoLLM-iOS (~> 1.2.0)
- Porcupine-iOS (~> 3.0.1)

SPEC REPOS:
Expand All @@ -23,11 +23,11 @@ SPEC REPOS:

SPEC CHECKSUMS:
Cheetah-iOS: d98a5edcbf3b74dda6027aeac6a8c0f5997a47a2
ios-voice-processor: 8e32d7f980a06d392d128ef1cd19cf6ddcaca3c1
ios-voice-processor: 00bf226d172c7006f565d6b6dbf2dc5e5b76938b
Orca-iOS: d50a0dbbf596f20c6c2e2f727f20f72ac012aa0e
picoLLM-iOS: dc03cd7e992c702ff34c667f9a35dd9a8084c061
Porcupine-iOS: 6d69509fa587f3ac0be1adfefb48e0c6ce029fff
picoLLM-iOS: 9ff6baa0b9e577d99491f4fa63f898a16fc6925c
Porcupine-iOS: b8408a28fe3df81ea8d8f3cf1e5a04823ffb71d3

PODFILE CHECKSUM: 1cc2ff3bc3e1abc97fbf7a3b3910e8d2b805f8b7
PODFILE CHECKSUM: da00234d72f8294a9db6b2710dde5563485a00e9

COCOAPODS: 1.15.2
2 changes: 1 addition & 1 deletion recipes/llm-voice-assistant/nodejs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"dependencies": {
"@picovoice/cheetah-node": "^2.0.2",
"@picovoice/orca-node": "^1.0.0",
"@picovoice/picollm-node": "1.1.0",
"@picovoice/picollm-node": "1.2.0",
"@picovoice/porcupine-node": "^3.0.3",
"@picovoice/pvrecorder-node": "^1.2.3",
"@picovoice/pvspeaker-node": "^1.0.1",
Expand Down
98 changes: 49 additions & 49 deletions recipes/llm-voice-assistant/nodejs/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@


"@eslint-community/eslint-utils@^4.2.0":
version "4.4.0"
resolved "https://registry.yarnpkg.com/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz#a23514e8fb9af1269d5f7788aa556798d61c6b59"
integrity sha512-1/sA4dwrzBAyeUoQ6oxahHKmrZvsnLCg4RfxW3ZFGGmQkSNQPFNLV9CUEFQP1x9EYXHTo5p6xdhZM1Ne9p/AfA==
version "4.4.1"
resolved "https://registry.yarnpkg.com/@eslint-community/eslint-utils/-/eslint-utils-4.4.1.tgz#d1145bf2c20132d6400495d6df4bf59362fd9d56"
integrity sha512-s3O3waFUrMV8P/XaF/+ZTp1X9XBZW1a4B97ZnjQF2KYWaFD2A8KyFBsrsfSjEmjn3RGWAIuvlneuZm3CUK3jbA==
dependencies:
eslint-visitor-keys "^3.3.0"
eslint-visitor-keys "^3.4.3"

"@eslint-community/regexpp@^4.4.0", "@eslint-community/regexpp@^4.6.1":
version "4.11.0"
resolved "https://registry.yarnpkg.com/@eslint-community/regexpp/-/regexpp-4.11.0.tgz#b0ffd0312b4a3fd2d6f77237e7248a5ad3a680ae"
integrity sha512-G/M/tIiMrTAxEWRfLfQJMmGNX28IxBg4PBz8XqQhqUHLFI6TL2htpIB1iQCj144V5ee/JaKyT9/WZ0MGZWfA7A==
version "4.12.1"
resolved "https://registry.yarnpkg.com/@eslint-community/regexpp/-/regexpp-4.12.1.tgz#cfc6cffe39df390a3841cde2abccf92eaa7ae0e0"
integrity sha512-CCZCDJuduB9OUkFkY2IgppNZMi2lBQgD2qzwXkEia16cge2pijY/aXi96CJMquDMn3nJdlPV1A5KrJEXwfLNzQ==

"@eslint/eslintrc@^2.1.4":
version "2.1.4"
Expand All @@ -29,17 +29,17 @@
minimatch "^3.1.2"
strip-json-comments "^3.1.1"

"@eslint/[email protected].0":
version "8.57.0"
resolved "https://registry.yarnpkg.com/@eslint/js/-/js-8.57.0.tgz#a5417ae8427873f1dd08b70b3574b453e67b5f7f"
integrity sha512-Ys+3g2TaW7gADOJzPt83SJtCDhMjndcDMFVQ/Tj9iA1BfJzFKD9mAUXT3OenpuPHbI6P/myECxRJrofUsDx/5g==
"@eslint/[email protected].1":
version "8.57.1"
resolved "https://registry.yarnpkg.com/@eslint/js/-/js-8.57.1.tgz#de633db3ec2ef6a3c89e2f19038063e8a122e2c2"
integrity sha512-d9zaMRSTIKDLhctzH12MtXvJKSSUhaHcjV+2Z+GK+EEY7XKpP5yR4x+N3TAcHTcu963nIr+TMcCb4DBCYX1z6Q==

"@humanwhocodes/config-array@^0.11.14":
version "0.11.14"
resolved "https://registry.yarnpkg.com/@humanwhocodes/config-array/-/config-array-0.11.14.tgz#d78e481a039f7566ecc9660b4ea7fe6b1fec442b"
integrity sha512-3T8LkOmg45BV5FICb15QQMsyUSWrQ8AygVfC7ZG32zOalnqrilm018ZVCw0eapXux8FtA33q8PSRSstjee3jSg==
"@humanwhocodes/config-array@^0.13.0":
version "0.13.0"
resolved "https://registry.yarnpkg.com/@humanwhocodes/config-array/-/config-array-0.13.0.tgz#fb907624df3256d04b9aa2df50d7aa97ec648748"
integrity sha512-DZLEEqFWQFiyK6h5YIeynKx7JlvCYWL0cImfSRXZ9l4Sg2efkFGTuFf6vzXjK1cq6IYkU+Eg/JizXw+TD2vRNw==
dependencies:
"@humanwhocodes/object-schema" "^2.0.2"
"@humanwhocodes/object-schema" "^2.0.3"
debug "^4.3.1"
minimatch "^3.0.5"

Expand All @@ -48,7 +48,7 @@
resolved "https://registry.yarnpkg.com/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz#af5b2691a22b44be847b0ca81641c5fb6ad0172c"
integrity sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA==

"@humanwhocodes/object-schema@^2.0.2":
"@humanwhocodes/object-schema@^2.0.3":
version "2.0.3"
resolved "https://registry.yarnpkg.com/@humanwhocodes/object-schema/-/object-schema-2.0.3.tgz#4a2868d75d6d6963e423bcf90b7fd1be343409d3"
integrity sha512-93zYdMES/c1D69yZiKDBj0V24vqNzB/koF26KPaagAfd3P/4gUlh3Dys5ogAK+Exi9QyzlD8x/08Zt7wIKcDcA==
Expand All @@ -75,29 +75,29 @@
fastq "^1.6.0"

"@picovoice/cheetah-node@^2.0.2":
version "2.0.2"
resolved "https://registry.yarnpkg.com/@picovoice/cheetah-node/-/cheetah-node-2.0.2.tgz#6d1153f0ada1e625d13b4521c8dcac5a62eeaf24"
integrity sha512-4bmE+OnvEqGoT3V1q+0wVbOvMy0nbSA+nAUHdG+GlMfJaEaC0QNzk9WTNevkV7eAEtbmjVj9tB2VkFfGNoQpNA==
version "2.0.3"
resolved "https://registry.yarnpkg.com/@picovoice/cheetah-node/-/cheetah-node-2.0.3.tgz#6b426ded58c2cf21e82a3282582f46698f3ddc32"
integrity sha512-BqcDV72PhjE41GQohlnfu/1xr52QTSMlpo504tTY+JgUHcoHnwT0jEp0AbpZgdXLIexYgH/dzUt8Ls12yXyCgQ==

"@picovoice/orca-node@^1.0.0":
version "1.0.0"
resolved "https://registry.yarnpkg.com/@picovoice/orca-node/-/orca-node-1.0.0.tgz#812728c3183a914eff6b3189dfa958ef4d44f2f7"
integrity sha512-YDTqJ5KsueBC4Nj0Zo287VF+/y7SRjXbOyHy8h66joJYPF0QNsz8oDCzbQO7hzymNbkFXd0crMPK+gQElvd83w==

"@picovoice/picollm-node@1.1.0":
version "1.1.0"
resolved "https://registry.yarnpkg.com/@picovoice/picollm-node/-/picollm-node-1.1.0.tgz#8f97ea5e46428af8a902dba0f264724d66999a96"
integrity sha512-vyVdHT/xQBy8LM1VAfxULivNS9gPIypIpvXE6r29IRKw8+VZtVQSv8c2+2O4qLiXD5FUIz8ErOa0A3rhAZHwyQ==
"@picovoice/picollm-node@1.2.0":
version "1.2.0"
resolved "https://registry.yarnpkg.com/@picovoice/picollm-node/-/picollm-node-1.2.0.tgz#9950706ea98d7021e3ff3a476d01426a7bd970d5"
integrity sha512-E5Af+zQ7hCCptHwLcH6ZYwtVGpJAA8cdwjSpq3hGyW4PxgksDfizzhPZbBrgMECXzFtOZjCerkZBdYsYI/D5rQ==

"@picovoice/porcupine-node@^3.0.3":
version "3.0.3"
resolved "https://registry.yarnpkg.com/@picovoice/porcupine-node/-/porcupine-node-3.0.3.tgz#c5c9f45da75d0710acedb2387e54c0d3439df45d"
integrity sha512-GL2ecilHYUsCiYLI9xHZasULWwkPwE/+B0u9mdSjb9WiSIEuYrPE5K7hEBToB+H6amibhXlbIX1/aQxX1sFflw==
version "3.0.4"
resolved "https://registry.yarnpkg.com/@picovoice/porcupine-node/-/porcupine-node-3.0.4.tgz#a4707810c99231d50f83e802907d2921b18c4941"
integrity sha512-cWFJSzQmEH45xVgfJ3z6S1pp0+0Tuki+7sBqamNa7K/s9j0ynW9WpJBeuMztRPrpwrDoAc7A2MZdK5UJ5wIebA==

"@picovoice/pvrecorder-node@^1.2.3":
version "1.2.3"
resolved "https://registry.yarnpkg.com/@picovoice/pvrecorder-node/-/pvrecorder-node-1.2.3.tgz#d0cb1d1ab82fbd2e914fda4e19b1dd0022609b48"
integrity sha512-6QOODFyGDgfWZI1NeXwMxylgaxJ+c5aVbvpDMGMen287eCajp/LDnxy3J1bZHceHsW3ilk/d4rCRLyifqcr24Q==
version "1.2.4"
resolved "https://registry.yarnpkg.com/@picovoice/pvrecorder-node/-/pvrecorder-node-1.2.4.tgz#1e67a1f82a144ad3c8e3f77c18fdbfe1ab5880cf"
integrity sha512-s8l6LtJnTHZ+FfIgXJZ9d8pKONSWs04v5q83F2zmfRr9IV1m7SQ5RlsmL0FO7NsB0GjIar3qHndryAQCjgSInw==

"@picovoice/pvspeaker-node@^1.0.1":
version "1.0.1"
Expand Down Expand Up @@ -209,9 +209,9 @@ acorn-jsx@^5.3.2:
integrity sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==

acorn@^8.9.0:
version "8.12.1"
resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.12.1.tgz#71616bdccbe25e27a54439e0046e89ca76df2248"
integrity sha512-tcpGyI9zbizT9JbV6oYE477V6mTlXvvi0T0G3SNIYE2apm/G5huBa1+K89VGeovbg+jycCrfhl3ADxErOuO6Jg==
version "8.14.0"
resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.14.0.tgz#063e2c70cac5fb4f6467f0b11152e04c682795b0"
integrity sha512-cl669nCJTZBsL97OF4kUQm5g5hC2uihk0NxY3WENAC0TYdILVkAyHymAntgxGkl7K+t0cXIrH5siy5S4XkFycA==

ajv@^6.12.4:
version "6.12.6"
Expand Down Expand Up @@ -301,20 +301,20 @@ [email protected]:
integrity sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==

cross-spawn@^7.0.2:
version "7.0.3"
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.3.tgz#f73a85b9d5d41d045551c177e2882d4ac85728a6"
integrity sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==
version "7.0.5"
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.5.tgz#910aac880ff5243da96b728bc6521a5f6c2f2f82"
integrity sha512-ZVJrKKYunU38/76t0RMOulHOnUcbU9GbpWKAOZ0mhjr7CX6FVrH+4FrAapSOekrgFQ3f/8gwMEuIft0aKq6Hug==
dependencies:
path-key "^3.1.0"
shebang-command "^2.0.0"
which "^2.0.1"

debug@^4.3.1, debug@^4.3.2, debug@^4.3.4:
version "4.3.6"
resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.6.tgz#2ab2c38fbaffebf8aa95fdfe6d88438c7a13c52b"
integrity sha512-O/09Bd4Z1fBrU4VzkhFqVgpPzaGbw6Sm9FEkBT1A/YBXQFGuuSxa1dN2nxgxS34JmKXqYx8CZAwEVoJFImUXIg==
version "4.3.7"
resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.7.tgz#87945b4151a011d76d95a198d7111c865c360a52"
integrity sha512-Er2nc/H7RrMXZBFCEim6TCmMk02Z8vLC2Rbi1KEBggpo0fS6l0S1nnapwmIi3yW/+GOJap1Krg4w0Hg80oCqgQ==
dependencies:
ms "2.1.2"
ms "^2.1.3"

deep-is@^0.1.3:
version "0.1.4"
Expand Down Expand Up @@ -369,15 +369,15 @@ eslint-visitor-keys@^3.3.0, eslint-visitor-keys@^3.4.1, eslint-visitor-keys@^3.4
integrity sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==

eslint@^8.13.0:
version "8.57.0"
resolved "https://registry.yarnpkg.com/eslint/-/eslint-8.57.0.tgz#c786a6fd0e0b68941aaf624596fb987089195668"
integrity sha512-dZ6+mexnaTIbSBZWgou51U6OmzIhYM2VcNdtiTtI7qPNZm35Akpr0f6vtw3w1Kmn5PYo+tZVfh13WrhpS6oLqQ==
version "8.57.1"
resolved "https://registry.yarnpkg.com/eslint/-/eslint-8.57.1.tgz#7df109654aba7e3bbe5c8eae533c5e461d3c6ca9"
integrity sha512-ypowyDxpVSYpkXr9WPv2PAZCtNip1Mv5KTW0SCurXv/9iOpcrH9PaqUElksqEB6pChqHGDRCFTyrZlGhnLNGiA==
dependencies:
"@eslint-community/eslint-utils" "^4.2.0"
"@eslint-community/regexpp" "^4.6.1"
"@eslint/eslintrc" "^2.1.4"
"@eslint/js" "8.57.0"
"@humanwhocodes/config-array" "^0.11.14"
"@eslint/js" "8.57.1"
"@humanwhocodes/config-array" "^0.13.0"
"@humanwhocodes/module-importer" "^1.0.1"
"@nodelib/fs.walk" "^1.2.8"
"@ungap/structured-clone" "^1.2.0"
Expand Down Expand Up @@ -706,10 +706,10 @@ minimatch@^3.0.5, minimatch@^3.1.1, minimatch@^3.1.2:
dependencies:
brace-expansion "^1.1.7"

[email protected].2:
version "2.1.2"
resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009"
integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==
ms@^2.1.3:
version "2.1.3"
resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.3.tgz#574c8138ce1d2b5861f0b44579dbadd60c6615b2"
integrity sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==

natural-compare-lite@^1.4.0:
version "1.4.0"
Expand Down
42 changes: 37 additions & 5 deletions recipes/llm-voice-assistant/python/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,37 @@ def tps(self) -> float:
return tps


class CompletionText(object):
def __init__(self, stop_phrases: list) -> None:
self.stop_phrases = stop_phrases
self.start: int = 0
self.text: str = ''
self.new_tokens: str = ''

def append(self, text: str) -> None:
self.text += text
end = len(self.text)

for stop_phrase in self.stop_phrases:
if stop_phrase in self.text:
contains = self.text.index(stop_phrase)
if end > contains:
end = contains
for i in range(len(stop_phrase) - 1, 0, -1):
if self.text.endswith(stop_phrase[:i]):
ends = len(self.text) - i
if end > ends:
end = ends
break

start = self.start
self.start = end
self.new_tokens = self.text[start:end]

def get_new_tokens(self) -> str:
return self.new_tokens


def orca_worker(access_key: str, connection, warmup_sec: float, stream_frame_sec: int = 0.03) -> None:
orca = pvorca.create(access_key=access_key)
orca_stream = orca.stream_open()
Expand Down Expand Up @@ -299,17 +330,18 @@ def llm_task(dialog, user_request, utterance_end_sec, main_connection):
'<|end|>', '<|user|>', '<|assistant|>', # Phi-3
}

completion = ['']
completion = CompletionText(stop_phrases)

def llm_callback(text: str) -> None:
picollm_profiler.tock()
completion[0] += text
if not any(x in completion[0] for x in stop_phrases):
completion.append(text)
new_tokens = completion.get_new_tokens()
if len(new_tokens) > 0:
main_connection.send({
'command': 'synthesize',
'text': text.replace('\n', ' . '),
'text': new_tokens.replace('\n', ' . '),
'utterance_end_sec': utterance_end_sec})
print(text, end='', flush=True)
print(f'{new_tokens}', end='', flush=True)

print(
f"\nLLM (say {'`Picovoice`' if keyword_model_path is None else 'the wake word'} to interrupt) > ",
Expand Down
2 changes: 1 addition & 1 deletion recipes/llm-voice-assistant/python/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
picollm==1.1.0
picollm==1.2.0
pvcheetah==2.0.1
pvorca==1.0.0
pvporcupine==3.0.2
Expand Down
2 changes: 1 addition & 1 deletion recipes/llm-voice-assistant/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"dependencies": {
"@picovoice/cheetah-web": "^2.0.0",
"@picovoice/orca-web": "^1.0.0",
"@picovoice/picollm-web": "~1.1.0",
"@picovoice/picollm-web": "~1.2.0",
"@picovoice/porcupine-web": "^3.0.3",
"@picovoice/web-voice-processor": "^4.0.9"
},
Expand Down
Loading
Loading