转 AI和Python 学习整理
在安装运行https://gitee.com/lukeewin/AudioSeparationGUI(该项目基于cam++实现的声音分类,能够对输入的音频,自动根据说话人进行分类。)这个项目的时候,本来安装的时候都是安装对应版本的
结果因为 PyTorch 官方目前尚未提供 CUDA 12.9 的预编译包。
根据 nvidia-smi 输出,你的驱动版本是 576.15,对应 CUDA Runtime 12.9,但 PyTorch 官方目前尚未提供 CUDA 12.9 的预编译包。
因此,你需要选择 PyTorch 官方支持的最新 CUDA 版本(目前为 CUDA 12.4),因为 驱动向下兼容,CUDA 12.4 运行时可以在 12.9 驱动上正常运行。...
|-转 AudioSeparationGUI 对输入的音频,自动根据说话人进行分类 20250817
代码可用,但部署的说明文档还是漏了很多情况,另外,模型分类的效果也要继续优化,1个人的语音被识别成了几个人的。不知道是用的模型不行还是参数设置的不够好,还在优化 20250817 07:44
解决FFmpeg6和FFmpeg5h和FFmpeg4都没成功调用的方法:
首先,卸载 conda-forge 版本的 ffmpeg:
conda uninstall ffmpeg -y
然后,从 pytorch 频道安装 ffmpeg:
conda install ffmpeg -c pytorch -y
在安装运行https://gitee.com/lukeewin/AudioSeparationGUI(该项目基于cam++实现的声音分类,能够对输入的音频,自动根据说话人进行分类。)这个项目的时候,本来安装的时候都是安装对应版本的
结果因为PyTorch 官方目前尚未提供 CUDA 12.9 的预编译包。
根据 nvidia-smi 输出,你的驱动版本是 576.15,对应 CUDA Runtime 12.9,但 PyTorch 官方目前尚未提供 CUDA 12.9 的预编译包。
因此,你需要选择 PyTorch 官方支持的最新 CUDA 版本(目前为 CUDA 12.4),因为 驱动向下兼容,CUDA 12.4 运行时可以在 12.9 驱动上正常运行。
✅ 推荐方案:使用 PyTorch + CUDA 12.4
🔧 步骤 1:彻底卸载现有 PyTorch
Kimi已经把不少问题解决了,最后也生成调试的日志文件了,但是错误日志,Kimi过于频繁提问,提示3小时后才能提问:
当前模型对话次数已达上限,3小时后为您提供更多使用次数
于是我去bing搜索引擎搜报错:
2025-08-17 07:00:55,656 - DEBUG - Loading FFmpeg6 2025-08-17 07:00:55,658 - DEBUG - Failed to load FFmpeg6 extension.
找到了一个文章ImportError: Failed to intialize FFmpeg extension. 里面的解决办法
【尝试】从 pytorch 频道安装 ffmpeg: 既然 torchaudio 来自 pytorch 频道,尝试从同一个频道安装 ffmpeg 可能会解决兼容性问题。 首先,卸载 conda-forge 版本的 ffmpeg: conda uninstall ffmpeg -y AI写代码 bash 1 然后,从 pytorch 频道安装 ffmpeg: conda install ffmpeg -c pytorch -y AI写代码 bash 1 安装完成后,再次进入 Python 检查后端: import torchaudio print(torchaudio.list_audio_backends()) quit() AI写代码 bash 1 2 3 看看这次 ffmpeg 是否出现在列表中。 如果 ffmpeg 出现在列表中,重启 Xinference 并测试 stream=True。 至此,我的问题得到解决 ———————————————— 版权声明:本文为CSDN博主「SKY的折腾日记」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。 原文链接:https://blog.csdn.net/qq_34034975/article/details/146553230
之前的日志是这样的,FFmpeg6和FFmpeg5h和FFmpeg4都没成功
2025-08-17 06:47:14,045 - DEBUG - Loading FFmpeg6 2025-08-17 06:47:14,047 - DEBUG - Failed to load FFmpeg6 extension. Traceback (most recent call last): File "G:\ProgramData\miniconda3\envs\as\lib\site-packages\torio\_extension\utils.py", line 116, in _find_ffmpeg_extension ext = _find_versionsed_ffmpeg_extension(ffmpeg_ver) File "G:\ProgramData\miniconda3\envs\as\lib\site-packages\torio\_extension\utils.py", line 108, in _find_versionsed_ffmpeg_extension _load_lib(lib) File "G:\ProgramData\miniconda3\envs\as\lib\site-packages\torio\_extension\utils.py", line 94, in _load_lib torch.ops.load_library(path) File "G:\ProgramData\miniconda3\envs\as\lib\site-packages\torch\_ops.py", line 1357, in load_library ctypes.CDLL(path) File "G:\ProgramData\miniconda3\envs\as\lib\ctypes\__init__.py", line 374, in __init__ self._handle = _dlopen(self._name, mode) FileNotFoundError: Could not find module 'G:\ProgramData\miniconda3\envs\as\Lib\site-packages\torio\lib\libtorio_ffmpeg6.pyd' (or one of its dependencies). Try using the full path with constructor syntax. 2025-08-17 06:47:14,076 - DEBUG - Loading FFmpeg5 2025-08-17 06:47:14,077 - DEBUG - Failed to load FFmpeg5 extension. Traceback (most recent call last): File "G:\ProgramData\miniconda3\envs\as\lib\site-packages\torio\_extension\utils.py", line 116, in _find_ffmpeg_extension ext = _find_versionsed_ffmpeg_extension(ffmpeg_ver) File "G:\ProgramData\miniconda3\envs\as\lib\site-packages\torio\_extension\utils.py", line 108, in _find_versionsed_ffmpeg_extension _load_lib(lib) File "G:\ProgramData\miniconda3\envs\as\lib\site-packages\torio\_extension\utils.py", line 94, in _load_lib torch.ops.load_library(path) File "G:\ProgramData\miniconda3\envs\as\lib\site-packages\torch\_ops.py", line 1357, in load_library ctypes.CDLL(path) File "G:\ProgramData\miniconda3\envs\as\lib\ctypes\__init__.py", line 374, in __init__ self._handle = _dlopen(self._name, mode) FileNotFoundError: Could not find module 'G:\ProgramData\miniconda3\envs\as\Lib\site-packages\torio\lib\libtorio_ffmpeg5.pyd' (or one of its dependencies). Try using the full path with constructor syntax. 2025-08-17 06:47:14,078 - DEBUG - Loading FFmpeg4 2025-08-17 06:47:14,079 - DEBUG - Failed to load FFmpeg4 extension. Traceback (most recent call last): File "G:\ProgramData\miniconda3\envs\as\lib\site-packages\torio\_extension\utils.py", line 116, in _find_ffmpeg_extension ext = _find_versionsed_ffmpeg_extension(ffmpeg_ver) File "G:\ProgramData\miniconda3\envs\as\lib\site-packages\torio\_extension\utils.py", line 108, in _find_versionsed_ffmpeg_extension _load_lib(lib) File "G:\ProgramData\miniconda3\envs\as\lib\site-packages\torio\_extension\utils.py", line 94, in _load_lib torch.ops.load_library(path) File "G:\ProgramData\miniconda3\envs\as\lib\site-packages\torch\_ops.py", line 1357, in load_library ctypes.CDLL(path) File "G:\ProgramData\miniconda3\envs\as\lib\ctypes\__init__.py", line 374, in __init__ self._handle = _dlopen(self._name, mode) FileNotFoundError: Could not find module 'G:\ProgramData\miniconda3\envs\as\Lib\site-packages\torio\lib\libtorio_ffmpeg4.pyd' (or one of its dependencies). Try using the full path with constructor syntax. 2025-08-17 06:47:14,079 - DEBUG - Loading FFmpeg 2025-08-17 06:47:14,079 - DEBUG - Failed to load FFmpeg extension. Traceback (most recent call last): File "G:\ProgramData\miniconda3\envs\as\lib\site-packages\torio\_extension\utils.py", line 116, in _find_ffmpeg_extension ext = _find_versionsed_ffmpeg_extension(ffmpeg_ver) File "G:\ProgramData\miniconda3\envs\as\lib\site-packages\torio\_extension\utils.py", line 106, in _find_versionsed_ffmpeg_extension raise RuntimeError(f"FFmpeg{version} extension is not available.") RuntimeError: FFmpeg extension is not available.
我试了后,现在是ffmpeg version 4.3,之前是ffmpeg version 7.0.2-essentials_bui1d-www.gyan.dev Copyright 2000-2024 the FFmpeg developers ...
|-转 SoloSpeech 项目安装和运行测试 20250817
实测了Kimi辅助编程还行,豆包辅助编程是真不行。20250817 21:32
腾讯元宝可以,还在测试和kimi那个更适合辅助编程 20250817 23:39
装 GPU 版 PyTorch
pip install torch==2.4.1+cu121 torchaudio==2.4.1+cu121 torchvision==0.19.1+cu121 --index-url https://download.pytorch.org/whl/cu121
先运行requirements-pip.txt
pytorch-lightning==2.4.0 torch==2.4.1 torch-ema==0.3 torch-optimizer==0.1.0 torch-stoi==0.2.3 torchaudio==2.4.1 torchmetrics==0.11.4 torchsde==0.2.6 torchvision==0.19.1 tornado==6.4.2 tqdm==4.63.0 matplotlib==3.7.5 pesq==0.0.4 wandb==0.19.1 pandas==2.0.3 diffusers==0.30 librosa==0.9.2 speechbrain==1.0.2 python_speech_features==0.6 einops==0.8.0 alias_free_torch==0.0.6 vector_quantize_pytorch==1.14.8
遇到报错
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/37/23/a30214b4c1f2bea24cc1197ef48d67824fbc41d5cf5472b17c37fef6002c/propcache-0.2.0-cp38-cp38-win_amd64.whl (45 kB) Building wheels for collected packages: pesq, python_speech_features Building wheel for pesq (setup.py) ... error error: subprocess-exited-with-error × python setup.py bdist_wheel did not run successfully. │ exit code: 1 ╰─> [32 lines of output] G:\ProgramData\miniconda3\envs\solospeech\lib\site-packages\setuptools\__init__.py:94: _DeprecatedInstaller: setuptools.installer and fetch_build_eggs are deprecated. !! ******************************************************************************** Requirements should be satisfied by a PEP 517 installer. If you are using pip, you can try `pip install --use-pep517`. ******************************************************************************** !! dist.fetch_build_eggs(dist.setup_requires) G:\ProgramData\miniconda3\envs\solospeech\lib\site-packages\setuptools\_distutils\dist.py:261: UserWarning: Unknown distribution option: 'tests_require' warnings.warn(msg) running bdist_wheel running build running build_py creating build\lib.win-amd64-cpython-38\pesq copying pesq\_pesq.py -> build\lib.win-amd64-cpython-38\pesq copying pesq\__init__.py -> build\lib.win-amd64-cpython-38\pesq copying pesq\cypesq.pyx -> build\lib.win-amd64-cpython-38\pesq copying pesq\dsp.h -> build\lib.win-amd64-cpython-38\pesq copying pesq\pesq.h -> build\lib.win-amd64-cpython-38\pesq copying pesq\pesqio.h -> build\lib.win-amd64-cpython-38\pesq copying pesq\pesqmain.h -> build\lib.win-amd64-cpython-38\pesq copying pesq\pesqpar.h -> build\lib.win-amd64-cpython-38\pesq copying pesq\dsp.c -> build\lib.win-amd64-cpython-38\pesq copying pesq\pesqdsp.c -> build\lib.win-amd64-cpython-38\pesq copying pesq\pesqmod.c -> build\lib.win-amd64-cpython-38\pesq running build_ext Compiling pesq/cypesq.pyx because it changed. [1/1] Cythonizing pesq/cypesq.pyx building 'cypesq' extension error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/ [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. ERROR: Failed building wheel for pesq Running setup.py clean for pesq Building wheel for python_speech_features (setup.py) ... done Created wheel for python_speech_features: filename=python_speech_features-0.6-py3-none-any.whl size=5876 sha256=cbee3eec30d4c5d493fab8a8271fbf705dd996f3b1009735613683a04c7dff22 Stored in directory: c:\users\administrator\appdata\local\pip\cache\wheels\20\98\cf\2543589065d9e69f0e70752d8ec6594f03f2615424a877b899 Successfully built python_speech_features Failed to build pesq ERROR: ERROR: Failed to build installable wheels for some pyproject.toml based projects (pesq) (solospeech) D:\python\SoloSpeech>
111111111111
根据kimi提供的方法ok了,Microsoft C++ Build Tools是安装上了,但是后面还是安装不上pesq
解决方法
1.安装 Microsoft C++ Build Tools
根据错误提示,你需要安装 Microsoft C++ Build Tools,这是一套独立的工具,用于编译 C++ 代码,而不需要安装完整的 Visual Studio。
步骤:
- 访问 Microsoft C++ Build Tools 官方下载页面。
- 下载并安装 Build Tools for Visual Studio。
-
在安装过程中,确保选择了以下组件:
- C++ compilers and standard libraries
- Windows SDK
- C++ CMake tools for Windows(可选,如果你使用 CMake)
- C++ AddressSanitizer(可选,如果你需要调试工具)
20250817 16:02
安装完成后,重新运行 pip install -r requirements-pip.txt,或者pip install pesq,还是之前的报错
在bing上搜 building 'cypesq' extension error: Microsoft Visual C++ 14.0 or greater is required. ...
|-转 python 多项目部署 优先考虑用Anaconda
Conda 查看源 在使用 Conda 时,查看当前配置的源可以帮助了解软件包的下载来源。以下是查看、添加和删除 Conda 源的常用方法。 查看当前 Conda 源 运行以下命令以查看当前配置的源: conda config --show-sources 此命令会列出所有已配置的源及其优先级。 添加新的 Conda 源 如果需要添加国内镜像源(如清华大学或中科大),可以使用以下命令: 清华大学镜像: conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/ conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/ 中国科技大学镜像: conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/free/ conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/main/ 删除已配置的 Conda 源 如果需要移除某个源,可以使用以下命令: conda config --remove channels <源地址> 例如,移除清华大学镜像: conda config --remove channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/ 恢复默认 Conda 源 若需恢复到默认源,可以清空所有自定义配置: conda config --remove-key channels 最佳实践 优先级设置:Conda 会按照添加顺序使用源,确保将常用的镜像源放在前面。 显示通道地址:启用显示通道地址功能,便于调试和确认包来源: conda config --set show_channel_urls yes 通过以上方法,您可以轻松管理 Conda 的安装源,提高下载速度和稳定性。
20250818 01:35...
|-转 espnet 声音分离
ESPnet 是一个端到端的语音处理工具包,涵盖端到端语音识别、文本转语音、语音翻译、语音增强、说话人分类、口语理解等。ESPnet 使用 pytorch 作为深度学习引擎,并遵循 Kaldi 风格的数据处理、特征提取/格式和配方,为各种语音处理实验提供完整的设置。 ESPnet is an end-to-end speech processing toolkit covering end-to-end speech recognition, text-to-speech, speech translation, speech enhancement, speaker diarization, spoken language understanding, and so on. ESPnet uses pytorch as a deep learning engine and also follows Kaldi style data processing, feature extraction/format, and recipes to provide a complete setup for various speech processing experiments.
太爽了,看来是找到宝了,果然是腾讯元宝 20250818
https://github.com/espnet/espnet 9.4K Star,2.3 Fork
在腾讯元宝上提问:
OpenSound/SoloSpeech-models 这个模型对中文处理效果太差,另外模型执行太慢了,有没有替代的模型
回答里的其他推荐的中文TTS模型和工具,提到了“PaddleSpeech 和 ESPnet”,看了下https://github.com/PaddlePaddle/PaddleSpeech已经两三年没人维护了,而https://github.com/espnet/espnet几天前还有人维护代码,特别是项目里的espnet2,2天前还有人维护(20250818)
项目太大了,没有找到详细的测试方式,于是在必应上搜:espnet 声音分离 20250818 01:47
在必应上搜“espnet2 声纹提取”,第一条结果就是...
|-转 ClearerVoice-Studio 安装测试遇到的问题,安装pysptk一直失败
必应搜索“espnet2 多人声音分离”又找到了
多人声音怎样单独提取
https://zhuanlan.zhihu.com/p/1937945345687548000
文章里提到的就是clearVoice
Building wheel for pysptk (setup.py) ... error
error: subprocess-exited-with-error
结果网上有提到可以去https://anaconda.org/上搜pysptk,结果去搜提示要登录,登录的时候又提示要注册,注册要人机验证,一直点验证转圈不通过,而且必须科学上网才能显示验证框,于是想到用racknerd的云主机去注册,给ubuntu的图形化界面安装,结果安装着安装着,我的v2ray服务也不能用了,服了,一件事情变成了几件事情。...
|-转 uvr5 bs roformer 爆显存以及关于huggingface的国内镜像hf-mirror.com
uvr5 bs roformer 爆显存(p104-100 8G显存顶不住,开始Uvr5选model_bs_roformer_ep_368_sdr_12.9628.ckpt的几天没问题不爆显存,之后就不行了)hf-mirror.com是huggingface的国内镜像,在上面搜索模型就可以下载
https://hf-mirror.com/ huggingface 国内镜像的国内镜像,在上面搜索模型就可以下载
https://hf-mirror.com/1Mohammad/model_bs_roformer/... 在上面找到了
https://hf-mirror.com/1Mohammad/model_bs_roformer/...
model_bs_roformer_ep_368_sdr_12.9628.ckpt 这个模型还有替代的占显存低些的bs_roformer模型吗
Kimi:bs_roformer 模型 显存使用 低 根据您的需求,您正在寻找一个显存占用较低的 BS-Roformer 模型作为替代品。搜索结果显示,存在一些其他版本的 BS-Roformer 模型,例如 model_bs_roformer_ep_317_sdr_12.9755,这可能是一个显存占用较低的替代选项。您可以尝试使用这个模型,看看它是否能满足您的需求,同时减少对显存的使用。 此外,您还可以考虑使用一些显存优化技术,比如 Offload KV Cache 功能,该功能通过将大多数层的 KV 缓存移至 CPU 来减少 GPU VRAM 使用。这可能有助于您在使用 BS-Roformer 模型时降低显存占用。
在B站搜“uvr5 bs roformer 爆显存”,搜索结果有视频:【MDX23一键包】2.4版本更新,BS-Roformer加入!视频提到
2.4版本的主要变动就是加入了BS-Roformer模型,该方案在mvsep.com上的SDR Vocals得分11.1205,堪称是跨越式提升了,不过值得注意的是,BS-Roformer 1297单模型得分就有10.9518,4G显存可跑且一首歌仅需一两分钟且听感上相当不错,具有极高性价比,数据量大的话可以酌情取舍,如果想要使用最简单的方式是将UVR更新到最新beta版本然后下载中心下载使用,十分推荐尝试。
...
|-转 用Kimi编程
我现在有个想法,用声音识别的模型,识别出源音频里的指定的人声,并把其提取出来,请给出合适的模型,并提供完整的python代码
根据你的需求,可以使用pyannote.audio库来实现指定人声的识别和提取。pyannote.audio是一个强大的音频处理库,能够进行说话人识别和语音分离。
以下是基于pyannote.audio的Python代码示例,用于识别并提取指定人声:
安装依赖
在运行代码之前,请确保安装了以下依赖:
pip install pyannote.audio pip install torch pip install scipy
完整代码示例
# _*_ coding: utf-8 _*_ # @Time : 2024/3/16 10:47 # @Author : Michael # @File : speaker_rec.py # @desc : import torch from pyannote.audio import Model, Pipeline, Inference from pyannote.core import Segment from scipy.spatial.distance import cosine def extract_speaker_embedding(pipeline, audio_file, speaker_label): """ 提取指定说话人的嵌入向量 """ diarization = pipeline(audio_file) speaker_embedding = None for turn, _, label in diarization.itertracks(yield_label=True): if label == speaker_label: segment = Segment(turn.start, turn.end) speaker_embedding = inference.crop(audio_file, segment) break return speaker_embedding def recognize_speaker(pipeline, audio_file, speaker_embeddings): """ 识别给定音频中的说话人 """ diarization = pipeline(audio_file) speaker_turns = [] for turn, _, speaker_label in diarization.itertracks(yield_label=True): # 提取切片的声纹特征 embedding = inference.crop(audio_file, turn) distances = {} for speaker, embeddings in speaker_embeddings.items(): # 计算与已知说话人的声纹特征的余弦距离 distances[speaker] = min([cosine(embedding, e) for e in embeddings]) # 选择距离最小的说话人 recognized_speaker = min(distances, key=distances.get) speaker_turns.append((turn, recognized_speaker)) return speaker_turns def extract_speaker_audio(audio_file, speaker_turns, output_file): """ 提取指定说话人的音频片段 """ from pydub import AudioSegment audio = AudioSegment.from_wav(audio_file) extracted_audio = AudioSegment.silent(duration=0) for turn, speaker in speaker_turns: start_ms = int(turn.start * 1000) end_ms = int(turn.end * 1000) extracted_audio += audio[start_ms:end_ms] extracted_audio.export(output_file, format="wav") if __name__ == "__main__": token = "hf_***" # 请替换为您的Hugging Face Token # 加载声音分离识别模型 pipeline = Pipeline.from_pretrained( "pyannote/speaker-diarization-3.1", use_auth_token=token, # 在项目页面agree使用协议,并获取 Hugging Face Token ) # 加载声纹嵌入模型 embed_model = Model.from_pretrained("pyannote/embedding", use_auth_token=token) inference = Inference(embed_model, window="whole") # 假设您已经有一个包含不同人声的音频文件集,以及对应的人 audio_files = { "mick": "mick.wav", # mick的音频 "moon": "moon.wav", # moon的音频 } speaker_embeddings = {} for speaker, audio_file in audio_files.items(): diarization = pipeline(audio_file) for turn, _, speaker_label in diarization.itertracks(yield_label=True): embedding = extract_speaker_embedding(pipeline, audio_file, speaker_label) # 获取原始已知说话人的声纹特征 speaker_embeddings.setdefault(speaker, []).append(embedding) # 给定新的未知人物的音频文件 given_audio_file = "2_voice.wav" # 前半部分是 mick 说话,后半部分是 moon 说话 # 识别给定音频中的说话人 recognized_speakers = recognize_speaker(pipeline, given_audio_file, speaker_embeddings) print("Recognized speakers in the given audio:") for turn, speaker in recognized_speakers: print(f"Speaker {speaker} spoke between {turn.start:.2f}s and {turn.end:.2f}s") # 提取指定说话人的音频 target_speaker = "mick" # 指定要提取的说话人 target_turns = [(turn, speaker) for turn, speaker in recognized_speakers if speaker == target_speaker] extract_speaker_audio(given_audio_file, target_turns, f"{target_speaker}_extracted.wav")
代码说明
- 说话人嵌入提取:extract_speaker_embedding函数用于从音频文件中提取指定说话人的嵌入向量。
- 说话人识别:recognize_speaker函数通过比较嵌入向量来识别音频中的说话人。
- 音频提取:extract_speaker_audio函数使用pydub库从原始音频中提取指定说话人的音频片段。
注意事项
- 确保你有有效的Hugging Face Token,用于加载预训练模型。
- 你可能需要根据实际情况调整代码中的音频文件路径和说话人标签。
希望这段代码能帮助你实现指定人声的识别和提取! ...
|-转 Studio One 调试插件Techivation AI-Rack 一键智能混音
Techivation AI-Rack:一键智能混音,新手也能出专业音质!
Play the busiest part of the track and click "Learn" 中文翻译是:播放曲目中最繁忙的部分,然后点击“学习”...
|-转 在hf-mirror.com模型镜像站用代码下载模型遇到报错 speaker-diarization模型不让下载 20250820
Cannot access gated repo for url https://hf-mirror.com/pyannote/speaker-diarization-3.1/resolve/84fd25912480287da0247647c3d2b4853cb3ee5d/.gitattributes.
Access to model pyannote/speaker-diarization-3.1 is restricted. You must have access to it and be authenticated to access it. Please log in.
from huggingface_hub import snapshot_download import os # 设置环境变量 os.environ['HF_ENDPOINT'] = 'https://hf-mirror.com' os.environ["HF_DATASETS_CACHE"] = "D:/python/Tse/models" os.environ["HF_MODELS_CACHE"] = "D:/python/Tse/models" # 指定模型名称 model_name = "pyannote/speaker-diarization-3.1" # 指定您想要保存模型的本地目录 # local_dir = "D:/python/Tse/models/pyannote/speaker-diarization-3.1" local_dir = "D:/python/Tse/models" # 下载整个模型到指定的本地目录 snapshot_download(repo_id=model_name, cache_dir=local_dir)
报错如下
Cannot access gated repo for url https://hf-mirror.com/pyannote/speaker-diarization-3.1/resolve/84fd25912480287da0247647c3d2b4853cb3ee5d/.gitattributes. Access to model pyannote/speaker-diarization-3.1 is restricted. You must have access to it and be authenticated to access it. Please log in.
去hf-mirror查,说是要去Huggingface,问题Huggingface科学上网都访问不了,根本申请不了...
|-转 用腾讯元宝编程
运行代码是可用运行了,达不到效果,在优化的过程中,腾讯元宝卡住了,让我自己去查文档,没给最新的代码。于是我拿着代码和报错信息去找Kimi 20250820 0450
Kimi那边卡再模型下载了,pyannote/speaker-diarization模型不让下,Kimi就乱给了些方案,连3年不维护的项目都https://github.com/athena-team/athena都推荐出来了 20250820 0550
那在跑腾讯元宝看能不能解决 20250820 0626
我描述下我需求”我大概给你描述下我对音频处理的需求,音频是多人对话的,就比如86版西游记里的多人对话,个别地方可能会两三个人同时发声,我需要的是把这音频里指定的某个人的声音提取出来,音频基本都是人声,没有背景音乐。就比如1分钟的音频,送悟空在里面说了有20秒,不是一次说完的,是分几次说的,提取出把几段整合起来,尽量不要有其他人的声音。提取出的音频大概应该是20秒左右。要对中文语音识别效果好的模型“,现在代码能跑,但是无法识别提取到,2个音频是没问题的,要找到替代pyannote.audio 的方案
我现在有个想法,用声音识别的模型,识别出源音频里的指定的人声,并把其提取出来,请给出合适的模型,并提供完整的python代码。注意要中文语音识别好的模型
要实现从源音频中识别并提取指定的人声,这是一个相对复杂的任务,通常包含以下几个步骤:
🧠 一、任务拆解
你提出的需求可以拆解为以下几个子任务:
- 1.人声分离(Voice Separation):从混合音频中分离出不同说话人的声音(比如说话人A和说话人B),或者分离人声和背景音乐。→ 这一步不区分具体是谁,只分离出“人声”或“某个人声”。
- 2.说话人识别(Speaker Identification) 或 说话人分离(Speaker Diarization):判断/分离出“指定的人声”是谁,或者哪一段是人声属于目标说话人。→ 如果你要提取“指定的人声”,通常需要事先知道该说话人的声纹特征,或者通过某种方式标记目标说话人。
- 3.语音识别(ASR,Automatic Speech Recognition):将分离出来的语音转换为文字,通常用于验证或后续处理。→ 如果你只是想提取人声,这一步不是必须的;但如果你是想“识别出某个说了特定内容的人声”,那就需要。
- 4.目标人声提取(目标说话人提取 / Target Speaker Extraction, TSE):如果你已经知道目标说话人的声纹(embedding),可以直接提取该说话人的声音。这是目前学术界比较热门的方向。
✅ 推荐方案(结合你的需求:中文语音识别效果好 + 提取指定人声)
方案名称:目标说话人提取(Target Speaker Extraction, TSE)
如果你能提供目标说话人的一段参考音频(例如几秒钟该说话人讲话的音频),那么可以使用基于声纹的目标说话人提取模型,从混合音频中提取出该说话人的声音。
这是目前最接近你需求、且效果较好的方案。
🛠️ 推荐模型:SpeechBrain 的 TSE 模型 或者 WavLM + TSE 相关模型
目前开源且支持中文、效果不错的方案包括:
1. SpeechBrain - TSE (Target Speaker Extraction)
- •官方地址:https://speechbrain.github.io/提取人声(和音乐分离),再尝试说话人分离或识别✅ 能(有目标说话人几秒语音)推荐使用 目标说话人提取(TSE),输入混合音频 + 参考音频,直接提取目标人声。可用 WavLM + TSE 实现
📌 如果你能提供“目标说话人的参考音频”,我可以为你写出完整的 TSE 或 WavLM 声纹匹配 + 人声提取的 Python 代码!
📩 请告诉我:
- •你能否提供目标说话人的一段样音(比如5秒他/她讲话的音频)?
- •你的源音频是几个人在说话,还是人声+背景音乐?
- •你最终目标是“提取人声”还是“提取某人说的话并转成文字”?
有了这些信息,我可以给你定制化、可直接运行的完整 Python 代码!
你能否提供目标说话人的一段样音(比如5秒他/她讲话的音频) 。上传音频提示wav格式不支持
an)暂时都不支持用户直接上传音频或图片文件并让 AI 直接处理。
二、你的意思是:“你在尝试自己运行代码或使用某个工具(比如 Spleeter、WavLM),然后系统/工具提示你上传的 WAV 文件格式不支持”
✅ 情况分析:
这种情况通常是:
- •你用的工具(比如某些在线语音工具、Python 音频库、或者某些音频分离工具)对 WAV 文件的编码格式、采样率、位深度有要求;
- •比如:
- •文件可能不是标准的 PCM WAV(有可能是 MP3 被误命名为 .wav,或者压缩过的 WAV);
- •采样率不是 16kHz 或 44.1kHz;
- •是立体声(stereo),但工具只支持单声道(mono);
- •文件头有问题,不是标准的 WAV 容器。
🎧 工具期望的标准 WAV 格式通常是:
- •格式:PCM 编码
- •采样率:16000 Hz(或 44100 Hz)
- •声道:单声道(mono)
- •位深度:16-bit
如果你的音频不是这种标准格式,某些工具(比如 WavLM、Spleeter、SpeechBrain)可能会报错或无法处理。
✅ 解决方案(根据你的实际目标)
🎯 如果你的目标是:
“我有一段目标说话人的音频(比如5秒),我想用它作为参考,从一段混合音频中提取出该说话人的声音。”
但你现在无法直接上传音频给我,那么可以按如下方式操作:
✅ 方法一:你自己处理音频,然后我提供完整可运行的代码
步骤 1:你自己准备好两段音频文件(本地即可,不用上传给我)
- 1.目标说话人音频(参考音频)
- •长度:5~10秒
- •内容:目标说话人清晰讲话
- •格式:建议用手机或电脑录音,保存为.wav文件
- •要求(如有可能):
- •单声道(mono)
- •采样率 16kHz 或 44.1kHz
- •PCM 编码(可以用 Audacity / FFmpeg 检查/转换)
- 2.混合音频(你想要分离出目标说话人的那个音频文件)
- •可以是多人对话,或者人声+背景音
- •同样保存为.wav格式
🔧 如果你不确定你的音频是否符合要求,可以用免费工具 Audacity转换/录制。...
|-转 Conda国内镜像源
中科大镜像源
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/main/ conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/free/ conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/conda-forge/ conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/msys2/ conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/bioconda/ conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/menpo/
清华镜像源
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/pro conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
阿里镜像源
conda config --add channels http://mirrors.aliyun.com/anaconda/pkgs/main conda config --add channels http://mirrors.aliyun.com/anaconda/pkgs/r conda config --add channels http://mirrors.aliyun.com/anaconda/pkgs/msys2
1 ...
|-转 数字对象标识符 (DOI)
必应搜索:hugging face 模型的唯一字符
https://hugging-face.cn/docs/hub/doi
数字对象标识符 (DOI)
Hugging Face Hub 提供为您的模型或数据集生成 DOI 的可能性。DOI(数字对象标识符)是唯一标识数字对象的字符串,可以是文章、图表,包括数据集和模型。DOI 与对象元数据相关联,包括对象的 URL、版本、创建日期、描述等。它们是研究和学术界普遍接受的数字资源引用方式;它们类似于图书的 ISBN。...
|-转 在创建conda环境时,如果不指定Python版本,conda将不会默认安装Python。
默认安装情况
使用基础环境的Python版本:当你创建一个新的conda环境时,如果没有指定Python版本,conda会使用当前基础环境(如base)的Python版本作为新环境的默认配置。例如,如果基础环境是Python 3.9.12,则新环境也会默认安装3.9.12。
创建纯净环境:如果你希望创建一个没有任何包的纯净环境,可以使用如下命令:
conda create -n myenv --no-default-packages
这样就会创建一个没有任何额外包的环境,包括Python。...
|-转 whisperx 的使用 音频处理
ValueError: Requested float16 compute type, but the target device or backend do not support efficient float16 computation.
ValueError:请求的 float16 计算类型,但目标设备或后端不支持高效的 float16 计算。
我看到代码里面要调用cuda,于是按照我电脑上cuda的版本12.9找了命令安装
pip install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu129
结果,出了各种问题。 下面是报错和代码。之后再网上查
whisperx要安装特点的cuda版本和对应特定的
pip install torch==2.5.1 torchvision==0.20.1 torchaudio==2.5.1 --index-url https://download.pytorch.org/whl/cu121
WhisperX在Windows 11下的CUDA环境配置指南
(speaker-splitter) D:\python\speaker-splitter> (speaker-splitter) D:\python\speaker-splitter>python w.py G:\ProgramData\miniconda3\envs\speaker-splitter\Lib\site-packages\ctranslate2\__init__.py:8: UserWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html. The pkg_resources package is slated for removal as early as 2025-11-30. Refrain from using this package or pin to Setuptools<81. import pkg_resources G:\ProgramData\miniconda3\envs\speaker-splitter\Lib\site-packages\pyannote\audio\core\io.py:212: UserWarning: torchaudio._backend.list_audio_backends has been deprecated. This deprecation is part of a large refactoring effort to transition TorchAudio into a maintenance phase. The decoding and encoding capabilities of PyTorch for both audio and video are being consolidated into TorchCodec. Please see https://github.com/pytorch/audio/issues/3902 for more information. It will be removed from the 2.9 release. torchaudio.list_audio_backends() G:\ProgramData\miniconda3\envs\speaker-splitter\Lib\site-packages\speechbrain\utils\torch_audio_backend.py:57: UserWarning: torchaudio._backend.list_audio_backends has been deprecated. This deprecation is part of a large refactoring effort to transition TorchAudio into a maintenance phase. The decoding and encoding capabilities of PyTorch for both audio and video are being consolidated into TorchCodec. Please see https://github.com/pytorch/audio/issues/3902 for more information. It will be removed from the 2.9 release. available_backends = torchaudio.list_audio_backends() Xet Storage is enabled for this repo, but the 'hf_xet' package is not installed. Falling back to regular HTTP download. For better performance, install the package with: `pip install huggingface_hub[hf_xet]` or `pip install hf_xet` config.json: 2.80kB [00:00, 2.80MB/s] vocabulary.txt: 460kB [00:00, 1.96MB/s] tokenizer.json: 2.20MB [00:00, 5.96MB/s] model.bin: 100%|██████████████████████████████████████████████████████████████████| 3.09G/3.09G [04:09<00:00, 12.4MB/s] Traceback (most recent call last): File "D:\python\speaker-splitter\w.py", line 16, in File "G:\ProgramData\miniconda3\envs\speaker-splitter\Lib\site-packages\whisperx\__init__.py", line 21, in load_model return asr.load_model(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "G:\ProgramData\miniconda3\envs\speaker-splitter\Lib\site-packages\whisperx\asr.py", line 336, in load_model model = model or WhisperModel(whisper_arch, ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "G:\ProgramData\miniconda3\envs\speaker-splitter\Lib\site-packages\faster_whisper\transcribe.py", line 663, in __init__ self.model = ctranslate2.models.Whisper( ^^^^^^^^^^^^^^^^^^^^^^^^^^^ ValueError: Requested float16 compute type, but the target device or backend do not support efficient float16 computation.
11
代码入下
import whisperx import gc import os import warnings warnings.filterwarnings("ignore", category=UserWarning) os.environ["HUGGINGFACE_HUB_CACHE"] = r"D:\python\speaker-splitter\models" # 可选,不影响核心功能 os.environ["HF_ENDPOINT"] = "https://hf-mirror.com" # 国内镜像 os.environ["HUGGINGFACE_HUB_TIMEOUT"] = "60" os.environ["HUGGINGFACE_HUB_DOWNLOAD_TIMEOUT"] = "60" device = "cuda" audio_file = "input.wav" batch_size = 16 # reduce if low on GPU mem 16改为 8 compute_type = "float16" # change to "int8" if low on GPU mem (may reduce accuracy) # 1. Transcribe with original whisper (batched) model = whisperx.load_model("large-v2", device, compute_type=compute_type) # save model to local path (optional) # model_dir = "/path/" # model = whisperx.load_model("large-v2", device, compute_type=compute_type, download_root=model_dir) audio = whisperx.load_audio(audio_file) result = model.transcribe(audio, batch_size=batch_size) print(result["segments"]) # before alignment # delete model if low on GPU resources # import gc; import torch; gc.collect(); torch.cuda.empty_cache(); del model # 2. Align whisper output model_a, metadata = whisperx.load_align_model(language_code=result["language"], device=device) result = whisperx.align(result["segments"], model_a, metadata, audio, device, return_char_alignments=False) print(result["segments"]) # after alignment # delete model if low on GPU resources # import gc; import torch; gc.collect(); torch.cuda.empty_cache(); del model_a # 3. Assign speaker labels diarize_model = whisperx.diarize.DiarizationPipeline(use_auth_token=YOUR_HF_TOKEN, device=device) # add min/max number of speakers if known diarize_segments = diarize_model(audio) # diarize_model(audio, min_speakers=min_speakers, max_speakers=max_speakers) result = whisperx.assign_word_speakers(diarize_segments, result) print(diarize_segments) print(result["segments"]) # segments are now assigned speaker IDs
20250821 03:17 ...
|-转 Win10系统 Trae的使用 关于powershell报错: 因为在此系统上禁止运行脚本
powershell报错: 因为在此系统上禁止运行脚本 解决办法,永久的允许策略,在powershell运行 Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned
在用Trea运行powershell时报错
错误的内容是
. : 无法加载文件 D:\Backup\Documents\WindowsPow erShell\profile.ps1,因为在此系统上禁止运行脚本 。有关详细信息,请参阅 https:/go.microsoft.com/ fwlink/?LinkID=135170 中的 about_Execution_Poli cies。 ile.ps1' + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~ + CategoryInfo : SecurityError: ( :) [],PSSecurityException + FullyQualifiedErrorId : UnauthorizedAcce ss
后来,我不通过Trea运行,直接运行
%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe
也报同样的错,看来不是Trea的问题。
然后我去问腾讯元宝
(高级)修改 PowerShell 执行策略(如果你确实需要运行该脚本)
⚠️ 注意:修改执行策略会降低安全限制,允许 PowerShell 运行脚本,有一定安全风险,请确保你了解自己在做什么,仅在信任的环境中使用。
如果你 确实需要加载这个profile.ps1脚本(比如它里面有你自定义的别名、环境配置、Conda 初始化命令等),那么你可以:
① 临时修改执行策略(仅当前 PowerShell 会话有效)
打开 PowerShell,运行:
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass
- •这会 仅对当前打开的 PowerShell 窗口 生效
- •然后你再手动运行你的profile.ps1(如果需要):
'D:\Backup\Documents\WindowsPowerShell\profile.ps1'
② 永久修改执行策略(不推荐,除非你非常清楚风险)
如果你想 永久允许运行本地脚本(比如RemoteSigned),可以运行:
Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned
🔒 推荐使用RemoteSigned,意思是:
- •✅ 允许运行你 自己电脑上创建的 PowerShell 脚本
- •❌ 但要求从 网上下载的脚本必须经过数字签名,否则仍会被阻止
⚠️ 不要轻易使用Unrestricted或Bypass,它们会允许所有脚本运行,存在安全风险!
✅ 关于你提到的链接:
错误信息里有一个微软官方文档链接:
(注意这个链接少了一个斜杠,完整正确的应该是:https://go.microsoft.com/fwlink/?LinkID=135170)
它指向 PowerShell 的官方帮助文档:about_Execution_Policies
🔗 你可以点进去查看 PowerShell 的各种执行策略说明,以及如何管理脚本安全性。
但作为普通用户,你通常不需要深入了解,按照上述方案 1 或 2 操作即可。
✅ 总结
问题 | PowerShell 启动时尝试加载D:\Backup\Documents\WindowsPowerShell\profile.ps1,但系统禁止运行脚本(执行策略为 Restricted) |
---|---|
错误本质 | 执行策略(ExecutionPolicy)限制导致 PowerShell 拒绝运行任何脚本,包括用户的 profile 启动脚本 |
是否影响功能 | ❌ 一般不影响你运行python、conda、pip等常用命令,只是启动时报错 |
推荐解决方案 | 方案 2:删除或重命名该 profile.ps1 文件(路径:D:\Backup\Documents\WindowsPowerShell\profile.ps1) |
其他方案 | 如果你确实需要该脚本 → 修改执行策略为RemoteSigned(有风险,需谨慎);或者忽略该错误(如果无实际影响) |
✅ 你可以这样操作(推荐,最安全):
- 1.打开文件管理器,进入:
- 2.找到文件:profile.ps1
- 3.右键它 → 选择 “重命名” → 改为profile.ps1.bak或直接删除
- 4.重新打开 PowerShell / TRAE 终端,该错误将不再出现 ✅
🟢 如果这个 profile.ps1 是你之前自己配置的重要文件(比如自定义了 Conda 初始化、别名等),请告诉我,我可以帮你把关键内容迁移出来,放到一个安全的新位置!
否则,直接删除/重命名是最简单安全的解决方式。欢迎继续提问! 😊
Microsoft Windows [版本 10.0.19045.6216] (c) Microsoft Corporation。保留所有权利。 C:\Users\Administrator>Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned 'Set-ExecutionPolicy' 不是内部或外部命令,也不是可运行的程序 或批处理文件。 C:\Users\Administrator>
...
|-转 warp的使用
|-转 AI编程工具比较
claude Pro 版 每月 17 美元(年付)
warp pro 版 每月 15美元(年付)
感谢您关注华为云CodeArts盘古助手,此次免费试用因资源有限,主要优先支持企业用户,个人用户暂不开放,申请试用后我们会尽快处理您的申请,请您耐心等待。 再次感谢您的关注和理解,祝您工作顺利。
https://cursor.com/?utm_source=ai-bot.cn
Cursor是免费的,具体情况如下:
新用户可以享受14天的免费试用期,包括150次高速模型调用。
Cursor提供基础免费版,用户可以使用核心功能,但不支持高级功能。
在校学生可以通过简单的身份验证,获得一年免费的Pro版使用权限。
因此,Cursor确实有免费的使用选项。
通义灵码
抱歉,我理解错了您的问题。关于在通义平台中使用 PowerShell,需要澄清的是:
- 通义平台本身是一个AI服务平台,不直接提供操作系统级别的终端功能,包括 PowerShell。
- 如果您想在本地使用 PowerShell,可以按照我之前提到的方法在您的本地计算机上打开 PowerShell。
- 如果您在使用通义的某些开发工具或IDE插件,可能可以通过以下方式访问:
- 在集成开发环境(如VS Code)中使用内置终端
- 通过IDE的终端功能打开PowerShell(如果已安装)
- 如果您指的是在容器或云环境中:
- 可能需要通过SSH连接到远程环境
- 然后在远程环境中启动 PowerShell
您能否提供更多上下文,比如您具体是在哪个通义产品或服务中想要打开 PowerShell?这样我可以给您更准确的帮助。
Warp比较厉害,就是太贵,一个月要20美元左右。
Code Snippets AI 就是一个聊天机器的壳,要加入你自己的API Key才能用。
claude 的价格和官网是
Claude 的官网是 [https://claude.ai/](https://claude.ai/) 。
Claude 的价格因使用计划和模型不同而有所差异,以下是其主要的订阅计划和定价:
### 订阅计划
- **免费版**:***,但有使用限制,适合轻度用户。
- **Pro 版**:每月 17 美元(年付),提供比免费版更高的使用限额和优先访问权,还包括扩展思考功能、连接 Google Workspace 等功能。...
|-转 FastApi
fastapi-speaker-extractor/
│
├── app/
│ ├── __init__.py
│ ├── main.py # FastAPI 入口,定义路由 / 启动配置
│ ├── api/
│ │ ├── __init__.py
│ │ ├── endpoints.py # API 路由,如 /upload-and-extract
│ │ └── schemas.py # Pydantic 模型:请求和响应的数据结构
│ ├── services/
│ │ ├── __init__.py
│ │ ├── audio_processor.py # 核心业务逻辑:语音识别 + 说话人分离 + 音频提取
│ │ └── speaker_utils.py # 工具:声纹特征 / 匹配 / 说话人标签处理...