简体   繁体   English

使用 python 中的 ffmpeg 将音频文件转换为 mp3

[英]Convert audio files to mp3 using ffmpeg in python

I'm working on the BOT industry for Dyscord and I need to play a voice clip in a kinetic knowledge I have a 32-bit computer我正在为 Dyscord 从事 BOT 行业,我需要在动态知识中播放语音片段我有一台 32 位计算机

import discord
from discord.ext import commands
import os
client = commands.Bot(command_prefix="!")
@client.command()
async def play(ctx, url : str):
    print('We have logged in as {0.user}'.format(client))
    voiceChannel = discord.utils.get(ctx.guild.voice_channels, name="Lounge")
    await voiceChannel.connect()
    voice = discord.utils.get(client.voice_clients, guild=ctx.guild)

    voice.play(discord.FFmpegPCMAudio("song.mp3"))

@client.command()
async def ext(ctx):
    voice = discord.utils.get(client.voice_clients, guild=ctx.guild)
    await voice.disconnect()

client.run('token')


Heyo: I recommend checking out this GitHub repo:https://github.com/pariweshsubedi/python-ffmpeg-audio-converter嘿嘿:我建议查看这个 GitHub 回购:https://github.com/pariweshsubedi/python-ffmpeg-audio-converter

It'll help make things easier.这将有助于使事情变得更容易。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM