forked from politicahacker/lex-langchain
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adicionando plugin de historico e transcrição
- Loading branch information
Showing
6 changed files
with
215 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,4 +28,6 @@ flask_socketio | |
gunicorn | ||
eventlet | ||
|
||
huggingface-hub==0.17.3 | ||
huggingface-hub==0.17.3 | ||
|
||
openai-whisper |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
document.addEventListener("DOMContentLoaded", function() { | ||
// Injetar o botão de gravação no container de botões | ||
const buttonContainer = document.querySelector(".button-container"); | ||
const recordButton = document.createElement("button"); | ||
recordButton.id = "record-audio"; | ||
recordButton.innerHTML = '<i class="fa fa-microphone"></i>'; | ||
buttonContainer.appendChild(recordButton); | ||
|
||
var mediaRecorder; | ||
var audioChunks = []; | ||
|
||
// Inicializar MediaRecorder | ||
navigator.mediaDevices.getUserMedia({ audio: true }) | ||
.then(stream => { | ||
mediaRecorder = new MediaRecorder(stream); | ||
mediaRecorder.ondataavailable = event => { | ||
audioChunks.push(event.data); | ||
}; | ||
|
||
mediaRecorder.onstop = () => { | ||
var audioBlob = new Blob(audioChunks, { type: "audio/wav" }); | ||
// Você pode enviar audioBlob para o servidor aqui | ||
addIndicator('Lex esta transcrevendo seu audio...') | ||
socket.emit('audioMessage', audioBlob); | ||
var audioUrl = URL.createObjectURL(audioBlob); | ||
var audio = new Audio(audioUrl); | ||
audio.play(); | ||
|
||
audioChunks = []; | ||
}; | ||
}); | ||
|
||
// Função para começar a gravação | ||
function startRecording() { | ||
mediaRecorder.start(); | ||
document.getElementById("record-audio").innerHTML = '<i class="fa fa-stop"></i>'; | ||
} | ||
|
||
// Função para parar a gravação | ||
function stopRecording() { | ||
setTimeout(() => { | ||
mediaRecorder.stop(); | ||
document.getElementById("record-audio").innerHTML = '<i class="fa fa-microphone"></i>'; | ||
}, 300) | ||
} | ||
|
||
document.getElementById("record-audio").addEventListener("mousedown", function() { | ||
startRecording(); | ||
}); | ||
|
||
document.getElementById("record-audio").addEventListener("mouseup", function() { | ||
stopRecording(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.