Giter VIP home page Giter VIP logo

dgvoice's Introduction

dgVoice

GoDoc Go report Build Status Discord Gophers

dgVoice is a Go package that provides an example of adding opus audio and play file support for DiscordGo.

  • You must use the current develop branch of Discordgo
  • You must have ffmpeg in your path and Opus libs already installed.

This code should be considered just a proof of concept, or an example, of accomplishing this task and not a defacto standard.

Please send feedback on any performance improvements that can be made for sound quality, stability, or efficiency.

For help with this package or general Go discussion, please join the Discord Gophers chat server.

Getting Started

Installing

This assumes you already have a working Go environment, if not please see this page first.

go get github.com/bwmarrin/dgvoice

Usage Example

See example folder

dgvoice's People

Contributors

albertmoravec avatar bwmarrin avatar gidobossftw5731 avatar joshheinrichs avatar silvea12 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

dgvoice's Issues

Questions about managing audio playback

Hello,

Can you please propose on solutions for the following tasks (using this library):

  1. Pausing the audio.
  2. Finding out whether the audio ended playing/was paused/resumed.
  3. How do you play the audio that's being downloaded? Currently I'm downloading youtube videos with github.com/otium/ytdl lib, but can't play them until the files are not fully downloaded.

Thank you.

how do I down volume?

I could play audio by using dgvoice.PlayAudioFile() but it is too big volume.
How do I down the volume played by bot?

use ffmpeg for opus encoding

I've been writing a discord bot in elixir using this library https://github.com/cronokirby/alchemy

Unlike this library where an opus library is used, the author uses ffmpeg for opus encoding directly from the file stream. In order to do this, ffmpeg has to be compiled with libopus support. On macOS, its as simple as brew install ffmpeg --with-opus.

I've ported it over to Go. It's very crude and only for demonstration purposes but it works really well and eliminates the need for a executable like dca-rs or a go opus library.

https://github.com/nhooyr/botatouille/blob/7e1cd9d5a8d517fd43fd11599b2a62bf832a5c96/cmd/botatouille/music/music.go#L62-L104

Only issue is that if the goroutine reading from ffmpeg's stdout ever falls behind ffmpeg, it may read more than a single frame. Then it will try and send more than a single frame to discord which will cause the audio to get completely screwed up. I wanted to know if you think there is any way to fix this.

I think its highly unlikely because the goroutine has its own thread and is only reading from ffmpeg and not doing anything else but I'm not 100% sure. What do you think?

If you like this method, I can incorporate it into this library.

file not recognized: File format not recognized

command-line-arguments

C:\Go\pkg\tool\windows_amd64\link.exe: running gcc failed: exit status 1
C:\Users\username\AppData\Local\Temp\go-link-619833591\go.o: file not recognized: File format not recognized
collect2.exe: error: ld returned 1 exit status

Multiple channels?

Does this work with multiple voice channels?
I'm unsure when I read the code. (Well, apart from that KillPlayer obviously doesn't work with multiple)

Occasional crash when attempting to join VC

Pretty straight forward. When I do:

vc, err = s.ChannelVoiceJoin(e.GuildID, e.ChannelID, false, false)

it sometimes crashes, seemingly randomly. Sometimes it happens a several times a day, sometimes not at all. This isn't my first time running into this issue; I originally ran this same bot in nodeJS but this same connection problem created an unrecoverable WASM crash. This makes me thing it's probably a fundamental issue, rather than a one specifically with this library. Here's the error:

2020/11/09 03:00:51 error: timeout waiting for voice

and sometimes:

dgVoice: timeout waiting for voice

Very strange. I've also tried using matryer/try to catch and repeat the process, but it doesn't seem to do anything different (probably running on a separate goroutine). Any idea how I might investigate this one?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.