Giter Site home page Giter Site logo

Comments (20)

Gingko4ever avatar Gingko4ever commented on July 17, 2024 4

请问在windows下mlx库要如何平替?修改相关代码吗

from voice-assistant.

NJUShannon avatar NJUShannon commented on July 17, 2024 3

我周末更新完系统之后就能够正常运行了,笔记本配置为MBP M2 16G。不过因为内存的关系,目前只能加载6B的模型。从效果上来说,蛮一般的,有时候回答会直接从Prompt里摘取内容,有时候会陷入一直重复说话,一个回复里面一句话能重复十几次。

顺便去了解了下Bert-VITS2,这个蛮有意思的,不过看起来如果从回复及时朗读的话,性能还是比较大的问题。

from voice-assistant.

linyiLYi avatar linyiLYi commented on July 17, 2024 2

我很久以前遇到过这个问题,当时也是发现 conda 环境下 pyaudio 导入会报错。解决办法是不使用 anaconda,直接在主环境里运行这个程序,后来运行过几次之后不知道为什么在 conda 环境里也可以了。

from voice-assistant.

zsstssjxzzyxgs avatar zsstssjxzzyxgs commented on July 17, 2024 2

mlx的一些补充

在经过一些试验后,我意识到无法使用pip并非是python版本的原因,而是arm环境的原因。因为我曾执行过以下代码

arch -x86_64 zsh

按照mlx的文档,我改进了第一条代码,使其环境为arm架构

CONDA_SUBDIR=osx-arm64 conda create -n VoiceAI python=3.11  -c conda-forge

CONDA_SUBDIR=osx-arm64代表环境参数为osx-arm64,确保所有的软件和工具都是arm架构的。这可能也对于非M芯片用户也有效。
在使用该代码创建虚拟环境后,我顺利地实现了用pip安装,尽管我依然无法使用源码导入mlx(一样的错误)。同时我也发现,我现在使用的python可能并不是arm架构的,这可能是之前我无法下载mlx的祸首,因为mlx只支持arm架构。所以接下来我将尝试下载arm架构的python并修改环境参数。
@NJUShannon 感谢你的建议! 我目前是14.2的系统,并且通过pip install成功下载了mlx。事情可能和你说的一样,但据我所知修改名称应该不会解决大部分的兼容问题,所以我觉得升级系统是必要的。如果还是失败的话,也建议你通过这个代码查看你的python是否为arm架构

python -c "import platform; print(platform.processor())"

如果输出arm就是,不是的话,mlx文档的build and install会给你解决的方法。这是针对pip install 的解决方案。由于我没能完成源码导入,也希望你能想我分享你是如何成功通过源码导入mlx的。

新进展

感谢[linyiLYi]的思路分享。我尝试了在主环境中运行程序,但由于缺少mlx,所以目前来说仍没有结果。

ModuleNotFoundError: No module named 'mlx'

同时我也尝试了我的新环境,但令人沮丧的是,它仍然有问题,出现了以下的报错

ImportError: Error importing numpy: you should not try to import numpy from its source directory; please exit the numpy source tree, and relaunch your python intepreter from there.

其问题在于使用源文件夹导入numpy,但在我找到numpy并把它拖到桌面后,仍然无法解决这个问题。

更新的进展

家人们,它没问题!在我删除anaconda下载minianaconda后,它开始运行了!

截屏2023-12-16 14 22 56

昨天码的字结果没发上[捂脸],村里果然没通网。本来想重复一遍截屏报错的,结果阴差阳错运行了
具体方法如下:我在base中通过cd打开我的voice-assistant-main文件夹,将六行代码直接丢进去,python main.py就运行了。python太玄学了。
但它依然没能成功,我遇到了和[annidy]一样的问题,
截屏2023-12-16 14 42 28
这是一个简单却容易忽略的错误,其原因在于main中路径描述的模型名与实际模型名不同,修改后可成功启动。
对我的电脑来说34B占用过大导致运行失败,应当采用更小模型。
试验完毕,结论为:无论是34B还是6B,都不是8G物理内存的电脑应当承受的。

from voice-assistant.

zsstssjxzzyxgs avatar zsstssjxzzyxgs commented on July 17, 2024 2

你好[ulooocom]
对于OSError: [Errno -9998] Invalid number of channels,这里有相关解决方法

https://blog.csdn.net/dreautumn/article/details/131531996

这应该是由于通道数设置不匹配导致的OSError,因为在原main代码中设置了CHANNELS=1表示希望使用单声道,但在错误消息中表示你尝试使用CHANNELS=2立体声模式打开流。可能你并没有给你的hear立体声模式的权限,

如果你还有什么问题,你可以询问ChartGPT,虽然它无法解决所有问题,但它在解释代码原理方面很有作用。

from voice-assistant.

wxharry avatar wxharry commented on July 17, 2024 2

有个问题,为什么whisper在windows下要替换成speech_recognition?直接用有问题吗?

本项目中的whisper是用的mlx, 这是苹果芯片M系列上的库,所以在windows下要替换成别的库。

from voice-assistant.

alfred-liang avatar alfred-liang commented on July 17, 2024 1

可以跑起来,但是跑起来后不知道要怎么使用,我对着电脑说话,终端没什么反应。要点一下f5麦克风那个图标然后说话吗,有时候能识别,但是速度很慢很慢,回答也是很啰嗦🤣,要怎么样才能和它流畅对话呢,设备是M1Pro 32g
image

from voice-assistant.

Zhaoli2042 avatar Zhaoli2042 commented on July 17, 2024 1

用的是m2 ultra, 先尝试的是6b的模型,感觉还挺有意思的。就是有时会抽风。我叹了口气(input就是sigh),她之后说了一堆脑筋急转弯的东西,而且还把同样的东西重复了三次。。。接下来试试34b。不过运行起来还是很开心的。

一个小点:我的电脑报了ffmpeg的error,然后我才发现我conda没装这个:
conda install -c conda-forge ffmpeg

from voice-assistant.

zsstssjxzzyxgs avatar zsstssjxzzyxgs commented on July 17, 2024

mlx源码导入

好像忘了什么,oh,对,如果你mlx没能导入,那你一定还记得mlx源码导入。

事先声明,如果你的目的只是导入项目而对讨论没有兴趣的话,那么我认为以下内容帮不到你,因为我也没能成功。我认为这与环境的python版本有关而非与导入方式有关。但如果和我一样对代码很感兴趣的话,作为一个小白以下内容可能对你有用,因为它让我学习到了很多。

mlx是苹果发布的机器学习框架,题主称其whisper函数就是基于mlx开发的。因此,mlx对于程序是不可缺少的。
我首先询问了gpt如何解决,gpt向我提出了wheel导入的方法

pip install path/to/wheel文件名

我按照gpt的说法,找到了mlx的wheel文件

https://pypi.org/project/mlx/#files

但很可惜,没能成功。

pip install /Users/name/Desktop/program/voice-assistant-main/mlx-0.0.5-cp310-cp310-macosx_14_0_arm64.whl

ERROR: mlx-0.0.5-cp310-cp310-macosx_14_0_arm64.whl is not a supported wheel on this platform.

在mlx的文档中我查找到了下载code导入的方法

https://ml-explore.github.io/mlx/build/html/install.html

由于方法一已经使用过了,我采用的是使用python API的方法。方法如下:
//下载pybind11(我也不清楚是什么)

pip install "pybind11[global]"
conda install pybind11
brew install pybind11

//用pip构建并下载

env CMAKE_BUILD_PARALLEL_LEVEL="" pip install .

其中,env代指创建的虚拟环境;CMAKE_BUILD_PARALLEL_LEVEL=""设置环境变量,设置为空可能是为了禁用并行构建;’pip install .‘ ,其中‘ . '代表目录下的项目,该指令会自行查找项目中的setup.py并用setuptools来安装。因此我将下载的文件夹也放入voice-assistant-main,通过cp在voice-assistant-main中打开并执行了以上命令。

//在此报错

error: subprocess-exited-with-error

× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.

from voice-assistant.

DODOTAX avatar DODOTAX commented on July 17, 2024

牛逼啊楼主

from voice-assistant.

NJUShannon avatar NJUShannon commented on July 17, 2024

mlx这个问题其实是因为在pypi源上只有macosx_13_0,macosx_14_0,以及python38,39,310,311,312的支持。所以如果不在这10个组合里,通过pip install mlx是无法找到这个mlx包的。

我的电脑是macOS Monterey,也就是macosx_12_0,conda环境指定的python版本为3.11。在这样的配置下,通过修改下载的mlx安装包mlx-0.0.5-cp311-cp311-macosx_13_0_arm64.whl (3.11版本python,macos版本13),并将其重命名成mlx-0.0.5-cp311-cp311-macosx_12_0_arm64.whl ,是能够安装mlx成功的。然而,在执行时,报了找不到一个系统库的错,查看对应路径,发现内容的确不一样,猜测可能是13和12的系统差异。目前准备更新系统再试试看。

from voice-assistant.

ulooocom avatar ulooocom commented on July 17, 2024

M2 MAX 64G内存,一直遇到这个报错,调整 CHANNELS 参数无效,看过pyaudio的文档,以及重装也无用。

[I] ◆ voice-assistant git:(main) ✗ ❯❯❯ python main.py (VoiceAI)
Listening...
Traceback (most recent call last):
File "/Users/fusc/Developer/AI/voice-assistant/main.py", line 174, in
record_audio()
File "/Users/fusc/Developer/AI/voice-assistant/main.py", line 46, in record_audio
stream = audio.open(format=FORMAT, channels=2, rate=RATE, input=True, input_device_index=MIC_IDX, frames_per_buffer=CHUNK)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/fusc/miniconda3/envs/VoiceAI/lib/python3.11/site-packages/pyaudio/init.py", line 639, in open
stream = PyAudio.Stream(self, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/fusc/miniconda3/envs/VoiceAI/lib/python3.11/site-packages/pyaudio/init.py", line 441, in init
self._stream = pa.open(**arguments)
^^^^^^^^^^^^^^^^^^^^
OSError: [Errno -9998] Invalid number of channels
[I] ✖ 1 voice-assistant git:(main) ✗ ❯❯❯ hear (VoiceAI)
No
No
No
No hello
No hello
No hello
^Zfish: Job 2, 'hear' has stopped
[I] ✖ 1 voice-assistant git:(main) ✗ ❯❯❯

from voice-assistant.

melvinz79 avatar melvinz79 commented on July 17, 2024

有个问题,为什么whisper在windows下要替换成speech_recognition?直接用有问题吗?

from voice-assistant.

zsstssjxzzyxgs avatar zsstssjxzzyxgs commented on July 17, 2024

这可能与所选ai版本有关,可能34B会更流畅。在题主的演示视频中,他使用128G+34B也用了5318ms

from voice-assistant.

melvinz79 avatar melvinz79 commented on July 17, 2024

现在这套whisper 是苹果m芯片专供,去官网下一套就行。

from voice-assistant.

DeeepMind avatar DeeepMind commented on July 17, 2024

mlx这个问题其实是因为在pypi源上只有macosx_13_0,macosx_14_0,以及python38,39,310,311,312的支持。所以如果不在这10个组合里,通过pip install mlx是无法找到这个mlx包的。

我的电脑是macOS Monterey,也就是macosx_12_0,conda环境指定的python版本为3.11。在这样的配置下,通过修改下载的mlx安装包mlx-0.0.5-cp311-cp311-macosx_13_0_arm64.whl (3.11版本python,macos版本13),并将其重命名成mlx-0.0.5-cp311-cp311-macosx_12_0_arm64.whl ,是能够安装mlx成功的。然而,在执行时,报了找不到一个系统库的错,查看对应路径,发现内容的确不一样,猜测可能是13和12的系统差异。目前准备更新系统再试试看。

所以目前Windows是无法安装这个库的,对吗?

from voice-assistant.

asdasdsdsdasdasdasd avatar asdasdsdsdasdasdasd commented on July 17, 2024

用的是m2 ultra, 先尝试的是6b的模型,感觉还挺有意思的。就是有时会抽风。我叹了口气(input就是sigh),她之后说了一堆脑筋急转弯的东西,而且还把同样的东西重复了三次。。。接下来试试34b。不过运行起来还是很开心的。

一个小点:我的电脑报了ffmpeg的error,然后我才发现我conda没装这个: conda install -c conda-forge ffmpeg

謝了老兄,我正想著ffmpeg是啥,沒想到一行代碼就搞定了

from voice-assistant.

Yeeler avatar Yeeler commented on July 17, 2024

我周末更新完系统之后就能够正常运行了,笔记本配置为MBP M2 16G。不过因为内存的关系,目前只能加载6B的模型。从效果上来说,蛮一般的,有时候回答会直接从Prompt里摘取内容,有时候会陷入一直重复说话,一个回复里面一句话能重复十几次。

顺便去了解了下Bert-VITS2,这个蛮有意思的,不过看起来如果从回复及时朗读的话,性能还是比较大的问题。

我的macbook pro是10年前的 没法跑这个代码 Windows 又没法跑这个代码 ....郁闷

from voice-assistant.

alfred-liang avatar alfred-liang commented on July 17, 2024

我周末更新完系统之后就能够正常运行了,笔记本配置为MBP M2 16G。不过因为内存的关系,目前只能加载6B的模型。从效果上来说,蛮一般的,有时候回答会直接从Prompt里摘取内容,有时候会陷入一直重复说话,一个回复里面一句话能重复十几次。
顺便去了解了下Bert-VITS2,这个蛮有意思的,不过看起来如果从回复及时朗读的话,性能还是比较大的问题。

我的macbook pro是10年前的 没法跑这个代码 Windows 又没法跑这个代码 ....郁闷

要换电脑了

from voice-assistant.

BCK123 avatar BCK123 commented on July 17, 2024

mlx这个包要怎么解决?Windows环境下

from voice-assistant.

Related Issues (15)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.