Music Collecting

博主热衷于尝试不同类型的音乐,并决定不再占用大量磁盘空间来存储听过的音乐,而是收集自己喜欢的节奏来创作故事,就像DJ们所做的那样。
I like to listen music, especially to try different ones. However, I downloaded a lot of music, most of which I have only listened once, when it cost up all my disk space, I have to delete them and it is a little pity to delete all. Now I find a good idea not to store all the music I listened but the rythm that I like. Moreover, there is another resean to do this. It is a secret. I want to use these collected music to tell stories like what the DJs do.

Let me just start now.

 

 


  1. 终于找到
  2. 心有灵犀的美好
  3. 一辈子暖暖的好
  4. 我永远爱你到老
  5. 为你到老.mp3
  6. http://www.rayfile.com/files/70feae33-a341-11dd-9290-0014221b798a/

 

  

  1. 我每天睡不着
  2. 想念你的微笑
  3. 你不知道
  4. 你对我多么重要
  5. 有了你
  6. 生命完整的刚好
  7. 睡不着.mp3
  8. http://www.rayfile.com/files/8465b0ba-a341-11dd-b24a-0014221b798a/

 

Run pip install --upgrade pip Requirement already satisfied: pip in /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages (25.2) Collecting speechrecognition>=3.10.0 (from -r requirements.txt (line 1)) Downloading speechrecognition-3.14.3-py3-none-any.whl.metadata (30 kB) Collecting pyttsx3>=2.90 (from -r requirements.txt (line 2)) Downloading pyttsx3-2.99-py3-none-any.whl.metadata (6.2 kB) Collecting pyaudio>=0.2.14 (from -r requirements.txt (line 3)) Downloading PyAudio-0.2.14.tar.gz (47 kB) Installing build dependencies: started Installing build dependencies: finished with status 'done' Getting requirements to build wheel: started Getting requirements to build wheel: finished with status 'done' Preparing metadata (pyproject.toml): started Preparing metadata (pyproject.toml): finished with status 'done' Collecting python-dotenv (from -r requirements.txt (line 4)) Downloading python_dotenv-1.1.1-py3-none-any.whl.metadata (24 kB) Collecting psutil (from -r requirements.txt (line 5)) Downloading psutil-7.1.1-cp36-abi3-macosx_11_0_arm64.whl.metadata (23 kB) Collecting playsound (from -r requirements.txt (line 6)) Downloading playsound-1.3.0.tar.gz (7.7 kB) Installing build dependencies: started Installing build dependencies: finished with status 'done' Getting requirements to build wheel: started Getting requirements to build wheel: finished with status 'error' error: subprocess-exited-with-error × Getting requirements to build wheel did not run successfully. │ exit code: 1 ╰─> [28 lines of output] Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 389, in <module> main() File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 373, in main json_out["return_val"] = hook(**hook_input["kwargs"]) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 143, in get_requires_for_build_wheel return hook(config_settings) ^^^^^^^^^^^^^^^^^^^^^ File "/private/var/folders/q0/wmf37v850txck86cpnvwm_zw0000gn/T/pip-build-env-73fj8g_y/overlay/lib/python3.11/site-packages/setuptools/build_meta.py", line 331, in get_requires_for_build_wheel return self._get_build_requires(config_settings, requirements=[]) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/private/var/folders/q0/wmf37v850txck86cpnvwm_zw0000gn/T/pip-build-env-73fj8g_y/overlay/lib/python3.11/site-packages/setuptools/build_meta.py", line 301, in _get_build_requires self.run_setup() File "/private/var/folders/q0/wmf37v850txck86cpnvwm_zw0000gn/T/pip-build-env-73fj8g_y/overlay/lib/python3.11/site-packages/setuptools/build_meta.py", line 512, in run_setup super().run_setup(setup_script=setup_script) File "/private/var/folders/q0/wmf37v850txck86cpnvwm_zw0000gn/T/pip-build-env-73fj8g_y/overlay/lib/python3.11/site-packages/setuptools/build_meta.py", line 317, in run_setup exec(code, locals()) File "<string>", line 6, in <module> File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/inspect.py", line 1258, in getsource lines, lnum = getsourcelines(object) ^^^^^^^^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/inspect.py", line 1240, in getsourcelines lines, lnum = findsource(object) ^^^^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/inspect.py", line 1077, in findsource Error: raise OSError('could not get source code') OSError: could not get source code [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. 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. Error: Process completed with exit code 1.
10-26
你遇到的错误是: ``` OSError: could not get source code ``` 发生在安装 `playsound==1.3.0` 时,执行到 `Getting requirements to build wheel` 阶段。 --- ## ✅ 错误原因分析 ### 🔍 核心问题: > ❌ **`playsound==1.3.0` 不兼容 Python 3.11(以及更高版本如 3.12/3.13)** 这个错误的根本原因是: ```python File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/inspect.py", line 1077, in findsource raise OSError('could not get source code') OSError: could not get source code ``` 👉 这是因为 `playsound` 的 `setup.py` 在构建过程中尝试使用 `inspect.getsource()` 获取源码,但当前环境只有 `.pyc` 编译文件或打包不完整,导致无法读取源代码 → 抛出异常。 📌 这是一个已知问题:[GitHub Issue #258](https://github.com/TaylorSMarks/playsound/issues/258) > ⚠️ `playsound` 自 2021 年后基本停止维护,**不再推荐用于新项目** --- ## ✅ 解决方案(推荐顺序) ### ✅ 方案 1:**完全移除 `playsound`,改用 `pygame.mixer` 替代**(✅ 强烈推荐) `pygame` 更强大、跨平台、支持现代 Python 版本。 #### 安装: ```bash pip install pygame ``` #### 替换代码示例: ```python # 原来这样写(会失败) from playsound import playsound playsound('alert.mp3') # 改为这样 import pygame import time pygame.mixer.init() pygame.mixer.music.load('alert.mp3') pygame.mixer.music.play() # 等待播放完成(可选) while pygame.mixer.music.get_busy(): time.sleep(0.1) ``` ✅ 优点: - 支持 MP3、WAV、OGG 等格式 - 兼容 Python 3.11+ 和所有操作系统 - 可控制音量、暂停、循环等 --- ### ✅ 方案 2:在 `requirements.txt` 中跳过 `playsound` 修改你的 `requirements.txt`: ```txt speechrecognition>=3.10.0 pyttsx3>=2.90 pyaudio>=0.2.14 python-dotenv psutil # playsound # 注释掉这一行 pygame>=2.5.0 # 添加替代库 ``` 然后正常安装: ```bash pip install -r requirements.txt ``` --- ### ✅ 方案 3:强制安装旧版 `playsound`(不推荐,临时 workaround) 虽然 `playsound==1.2.2` 可能能工作,但它仍然可能触发同样的问题。 你可以尝试: ```bash pip install "playsound==1.2.2" ``` 但如果报错: ``` Could not find a version that satisfies the requirement playsound==1.2.2 ``` 说明 PyPI 已经删除了该版本(因为作者撤回),那就**只能放弃**。 --- ### ✅ 方案 4:使用其他音频播放库(备选方案) | 库名 | 安装命令 | 特点 | |------|----------|------| | `simpleaudio` | `pip install simpleaudio` | 轻量级,支持 WAV 播放 | | `pydub + simpleaudio` | `pip install pydub simpleaudio` | 支持 MP3/WAV,需 `ffmpeg` | | `winsound` (仅 Windows) | 内置 | 只能播 `.wav`,阻塞主线程 | #### 示例:使用 `simpleaudio` 播放 WAV 文件 ```python from pydub import AudioSegment from simpleaudio import play_file # 加载 MP3 或 WAV sound = AudioSegment.from_mp3("alert.mp3") playback = sound.export(format="wav") play_file(playback) ``` 需要先安装: ```bash pip install pydub simpleaudio brew install ffmpeg # macOS sudo apt install ffmpeg # Linux ``` --- ## ✅ 推荐最终依赖列表(`requirements.txt`) ```txt speechrecognition>=3.10.0 pyttsx3>=2.90 pyaudio>=0.2.14 python-dotenv psutil pygame>=2.5.0 ``` 并确保你在代码中将所有 `playsound(...)` 替换为 `pygame.mixer` 实现。 --- ## ✅ 验证是否修复成功 运行以下命令测试安装: ```bash pip install --upgrade pip pip install -r requirements.txt ``` 如果不再出现 `OSError: could not get source code`,说明问题已解决。 再运行一个测试脚本验证功能: ```python # test_audio.py import pygame import os pygame.mixer.init() if not os.path.exists("test.mp3"): print("请准备一个 test.mp3 文件") else: pygame.mixer.music.load("test.mp3") pygame.mixer.music.play() print("正在播放...") while pygame.mixer.music.get_busy(): pass print("播放结束") ``` --- ## ✅ 总结 | 方法 | 是否推荐 | 说明 | |------|----------|------| | 使用 `pygame.mixer` 替代 `playsound` | ✅✅✅ 强烈推荐 | 功能强、兼容性好 | | 移除 `playsound` 不安装 | ✅✅ 推荐 | 最干净的做法 | | 安装旧版 `playsound==1.2.2` | ⚠️ 观望 | 很可能不可用 | | 手动打补丁 fork 仓库 | ❌ 不推荐 | 维护成本高 | ---
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值