mirror of
https://github.com/EvolutionAPI/evolution-audio-converter.git
synced 2025-07-13 15:14:50 -06:00
refactor: performance improvements
This commit is contained in:
parent
9da58560f7
commit
3021043836
6
main.go
6
main.go
@ -29,13 +29,11 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
// Carrega o arquivo .env
|
|
||||||
err := godotenv.Load()
|
err := godotenv.Load()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("Erro ao carregar o arquivo .env")
|
fmt.Println("Erro ao carregar o arquivo .env")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Inicializa a variável apiKey
|
|
||||||
apiKey = os.Getenv("API_KEY")
|
apiKey = os.Getenv("API_KEY")
|
||||||
if apiKey == "" {
|
if apiKey == "" {
|
||||||
fmt.Println("API_KEY não configurada no arquivo .env")
|
fmt.Println("API_KEY não configurada no arquivo .env")
|
||||||
@ -144,7 +142,6 @@ func processAudio(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Conversão e resposta
|
|
||||||
convertedData, duration, err := convertAudioToOpusWithDuration(inputData)
|
convertedData, duration, err := convertAudioToOpusWithDuration(inputData)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||||
@ -158,7 +155,6 @@ func processAudio(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
// Obtém a porta do arquivo .env ou usa a porta 8080 por padrão
|
|
||||||
port := os.Getenv("PORT")
|
port := os.Getenv("PORT")
|
||||||
if port == "" {
|
if port == "" {
|
||||||
port = "8080"
|
port = "8080"
|
||||||
@ -166,9 +162,7 @@ func main() {
|
|||||||
|
|
||||||
router := gin.Default()
|
router := gin.Default()
|
||||||
|
|
||||||
// Endpoint para processar o áudio
|
|
||||||
router.POST("/process-audio", processAudio)
|
router.POST("/process-audio", processAudio)
|
||||||
|
|
||||||
// Inicia o servidor na porta especificada
|
|
||||||
router.Run(":" + port)
|
router.Run(":" + port)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user