20260510-一个自动听歌、选歌、翻译、压制的项目

0 阅读3分钟

本人喜欢听HipHop\R&B等欧美歌曲,但英语水平还有待提升。在听新歌的时候,需要每周五听所有的新歌并筛选后加到自己的歌单,有十分喜欢的会进行翻译压制后上传到B站。但随着歌曲越来越同质化,每周五的筛选变成了一个耗时且低效的行动,往往花费了很大的时间却没有自己喜欢的音乐。于是就有了做这样一个项目的想法。

  1. 自动从spotify获取关注列表
  2. 利用艺人的名称到youtube爬虫,获取其对应的youtube Channel ID
  3. youtube针对每个channel提供rss订阅,通过rss获取艺人最新发布的视频
  4. 采用whisper提取音频,并获取歌曲的节奏、能量、词汇密度等参数
  5. 利用AI自动校正提取的英文音频
  6. 根据歌词及歌曲参数,去RAG中的品味collection进行匹配。将RAG中匹配到的内容作为few-shot给AI,然后由AI进行打分自动筛选
  7. 筛选通过的歌曲,根据歌词去RAG中的歌词collection进行匹配翻译示例和风格,作为few-shot给AI,然后由AI进行自动翻译
  8. 再将翻译后的歌词给到AI进行校正,提高翻译流畅度
  9. 由ffmpeg自动压制成包含双语的mv

技术栈

Python · FastAPI · RabbitMQ · PostgreSQL · Qdrant · Whisper · DeepSeek · FFmpeg · Next.js

image.png

后端提供API列表

  • @app_instance.middleware("http"):FastAPI 应用上注册一个 HTTP 中间件函数,使该函数对每个请求都“环绕”执行(在路由处理前后都能运行)。项目中用于为每个请求生成一个request id
  • @app_instance.get("/healthz"):用于检查服务是否正常运行
  • @app_instance.get("/readyz"):用于检查Qdrant、Rabbitmq是否已准备就绪
  • @app_instance.exception_handler:用于统一处理界面发生的异常
  • @app_instance.post("/create_task", response_model=TaskResponse): 创建任务,比如同步spotify关注列表,提取英文歌词等任务
  • @app_instance.get("/check_status/{task_id}"):查询任务执行状态
  • @app_instance.post("/v1/candidates/{candidate_id}/render", response_model=TaskResponse):压制最终视频请求
  • @app_instance.post("/v1/candidates/{candidate_id}/pipeline", response_model=CandidatePipelineResponse):将找到的艺人最新发布的歌曲(candidate)加入到pipeline中以执行工作流
  • @app_instance.post("/v1/candidates/{candidate_id}/pipeline/retry", response_model=CandidatePipelineRetryResponse):上面动作的重试
  • @app_instance.get("/v1/candidates/{candidate_id}/workflow-detail"):查询对应candidate的workflow detail
  • @app_instance.get("/list_tasks"):查询所有任务状态
  • @app_instance.get("/internal/phase2/reconcile"):项目最开始使用的是SQLite和Chromadb,后来迁移到PostgreSQL和Qdrant,这个是检查shadow write时写的内容是否一致
  • @app_instance.post("/internal/phase2/outbox/dispatch"):dispatch消息队列中的任务,给到对应worker执行
  • @app_instance.get("/internal/phase6/queue-topology"):查询队列拓扑
  • @app_instance.post("/internal/phase6/worker/handle"):worker处理任务的函数
  • @app_instance.post("/internal/phase3/spotify/sync-followed-artists",response_model=Phase3SpotifySyncResponse,):获取spotify关注列表
  • @app_instance.post("/internal/phase3/catalog/resync-active-artists",response_model=Phase3BatchRefreshResponse,):重新同步所有活跃artist的最新视频
  • @app_instance.get("/v1/artists", response_model=ArtistListResponse):前端页面artist tab展示页, 展示关注arist的状态
  • @app_instance.get("/v1/artists/{artist_id}/candidates",response_model=CandidateListResponse):查询对应artist的最新视频
  • @app_instance.post("/v1/artists/{artist_id}/resync",response_model=ArtistResyncResponse):重新同步对应artist
  • @app_instance.get("/v1/audit-queue", response_model=Phase4ListResponse):前端页面audit-queue tab展示页,展示需要人工审核或者AI正在审核的candidate
  • @app_instance.get("/v1/pipeline", response_model=Phase4ListResponse):前端页面pipeline tab展示页,展示正在工作流中的candidate的状态
  • @app_instance.get("/v1/library", response_model=Phase4ListResponse):前端页面library tab展示页,展示最终压制后的视频作品
  • @app_instance.get("/v1/artifacts/download"):下载对应作品
  • @app_instance.get("/v1/artifacts/{artifact_id}",response_model=ArtifactDetailResponse):获取对应作品的详细信息
  • @app_instance.get("/v1/audit-log", response_model=Phase4ListResponse):获取transcript/translation校正和筛选的日志
  • @app_instance.post("/v1/reviews/{review_id}/approve",response_model=ReviewDecisionResponse): 人工review的时候进行批准动作
  • @app_instance.post("/v1/reviews/{review_id}/reject",response_model=ReviewDecisionResponse): 人工review的时候进行拒绝动作
  • @app_instance.post("/v1/candidates/{candidate_id}/transcript",response_model=TranscriptSubmissionResponse,):提交提取的英文歌词
  • @app_instance.post("/v1/candidates/{candidate_id}/taste-audit",response_model=TasteAuditResponse,):提交筛选后的歌曲信息
  • @app_instance.post("/v1/candidates/{candidate_id}/translation",response_model=TranslationSubmissionResponse,):提交翻译后的歌词