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

Mac M1 下 sndfile 无法找到 #52

Open
3 tasks done
WangLaoShi opened this issue Jun 17, 2024 · 2 comments
Open
3 tasks done

Mac M1 下 sndfile 无法找到 #52

WangLaoShi opened this issue Jun 17, 2024 · 2 comments
Assignees
Labels
enhancement New feature or request env Related to execution environment help wanted Extra attention is needed

Comments

@WangLaoShi
Copy link

阅读 README.md 和 dependencies.md

  • 我已经阅读过 README.md 和 dependencies.md 文件

检索 issue 和 discussion

  • 我已经确认之前没有 issue 或 discussion 涉及此 BUG

检查 Forge 版本

  • 我已经确认问题发生在最新代码或稳定版本中

你的issues

错误如下:

/Users/laoshi/PycharmProjects/ChatTTS-Forge/.venv/lib/python3.9/site-packages/pydub/utils.py:170: RuntimeWarning: Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work
  warn("Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work", RuntimeWarning)
Traceback (most recent call last):
  File "/Users/laoshi/PycharmProjects/ChatTTS-Forge/.venv/lib/python3.9/site-packages/soundfile.py", line 267, in <module>
    _snd = _ffi.dlopen('sndfile')
  File "/Users/laoshi/PycharmProjects/ChatTTS-Forge/.venv/lib/python3.9/site-packages/cffi/api.py", line 150, in dlopen
    lib, function_cache = _make_ffi_library(self, name, flags)
  File "/Users/laoshi/PycharmProjects/ChatTTS-Forge/.venv/lib/python3.9/site-packages/cffi/api.py", line 832, in _make_ffi_library
    backendlib = _load_backend_lib(backend, libname, flags)
  File "/Users/laoshi/PycharmProjects/ChatTTS-Forge/.venv/lib/python3.9/site-packages/cffi/api.py", line 827, in _load_backend_lib
    raise OSError(msg)
OSError: ctypes.util.find_library() did not manage to locate a library called 'sndfile'

解决方案:

按照 dependencies.md 中的步骤,无法实现。

可以参考https://github.com/bastibe/python-soundfile/ 实现。

@WangLaoShi
Copy link
Author

我在代码中是这么实现的:

modules/api/impl/tts_api.py

try:
    # OSError: cannot load library '/*****_soundfile_data/libsndfile.dylib'
    import soundfile as sf
except:
    import os
    import platform

    # 获取当前系统名称
    system = platform.system()

    if system == 'Darwin':
        # 获取当前的DYLD_LIBRARY_PATH
        current_dyld_library_path = os.environ.get('DYLD_LIBRARY_PATH', '')

        # 要追加的路径
        new_dyld_library_path = '/opt/homebrew/lib'

        # 设置新的DYLD_LIBRARY_PATH,如果已存在则追加,否则设置为新值
        if current_dyld_library_path:
            os.environ['DYLD_LIBRARY_PATH'] = f"{new_dyld_library_path}:{current_dyld_library_path}"
        else:
            os.environ['DYLD_LIBRARY_PATH'] = new_dyld_library_path

        # 输出验证
        print(os.environ['DYLD_LIBRARY_PATH'])

        import soundfile as sf

@zhzLuke96 zhzLuke96 added enhancement New feature or request help wanted Extra attention is needed env Related to execution environment labels Jul 12, 2024
@atfa
Copy link

atfa commented Jul 30, 2024

conda install -c conda-forge libsndfile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request env Related to execution environment help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants