制作冥想音乐的程序
单独的文字音频 + 背景音乐音频合成程序:
from pydub import AudioSegment for_file = r"D:\个人\疗愈内在小孩.mp3" for_file = r"D:\个人\发大愿-for.mp3" for_file = r"D:\个人\拥抱内在回归真我.mp3" for_file = r"D:\个人\整合阴影认识真我的无限人格.mp3" # for_file = r"D:\个人\觉察负面情绪收回期待.mp3" for_file = r"D:\个人\转化成瘾欲望.mp3" for_file = r"D:\个人\消除日常匮乏感.mp3" for_file = r"D:\个人\感恩.mp3" for_file = r"D:\个人\家族链接.mp3" for_file = r"D:\个人\疗愈伤痛.mp3" for_file = r"D:\个人\疗愈童年伤痛看见内在小孩.mp3" background_file = r"D:\个人\催眠-伤感抒情.MP3" background_file = r"D:\个人\古风舒缓.MP3" background_file = r"D:\个人\时光不老.MP3" background_file = r"D:\个人\柔软触感.MP3" # background_file = r"D:\个人\秋的思念.MP3" background_file = r"D:\个人\风中的信.MP3" background_file = r"D:\个人\夜幕星河.MP3" background_file = r"D:\个人\感恩遇见.MP3" background_file = r"D:\个人\美丽的秋天.MP3" background_file = r"D:\个人\疗愈减压.MP3" background_file = r"D:\个人\亲爱的小孩.MP3" output_file = r"疗愈童年伤痛看见内在小孩.mp3" output_file = r"发大愿-冥想练习.mp3" output_file = r"拥抱内在回归真我-冥想练习.mp3" output_file = r"整合阴影认识真我无限人格-冥想练习.mp3" # output_file = r"觉察负面情绪收回期待-冥想练习.mp3" output_file = r"转化成瘾欲望-冥想练习.mp3" output_file = r"消除日常匮乏感-冥想练习.mp3" output_file = r"感恩-冥想练习.mp3" output_file = r"家族链接-冥想练习.mp3" output_file = r"疗愈伤痛-冥想练习.mp3" output_file = r"疗愈童年伤痛看见内在小孩-冥想练习.mp3" # 加载音频文件 audio = AudioSegment.from_file(for_file) background = AudioSegment.from_file(background_file) # 如果背景音频短于主要音频,则重复背景音乐直到达到所需长度 while len(background) < len(audio): background += background # 截取背景音频的长度与主音频相同 background = background[:len(audio)] # 插入3秒静音,使得主音频3秒后开始合并 silence = AudioSegment.silent(duration=3000) # 表示3000毫秒,即3秒的静音 audio = audio + silence # 在背景音前加上静音段 # 降低背景音量,确保主音频更清晰 background_lower = background - 5 # 根据需要调整减少的 dB # 为背景音乐的最后10秒应用淡出效果 fade_duration = 10000 # 10000毫秒 = 10秒 background_with_fade = background_lower.fade_out(fade_duration) # 混音两个音频文件(从3秒开始) output = background_with_fade.overlay(audio, position=3000, gain_during_overlay=0) # 导出最终合成音频 output.export(output_file, format="mp3")