
저는 Ubuntu 22.04 플랫폼을 사용하고 있습니다. c라는 이름의 간단한 푸시 버튼 GUI를 만들어 환경 변수 에 경로가 추가되는 위치 t2s
에 배치했습니다 . 버튼을 누르고 있는 동안 마이크의 음성이 임시 파일로 녹음됩니다. 버튼을 놓으면 GUI가 종료됩니다. 터미널 내에서 잘 작동하는 다음 줄을 실행합니다.~/.local/bin
PATH
t2s && notify-send -u normal -t 10000 "$( whispercpp -m /home/****/Desktop/2022-10/whisper.cpp/models/ggml-small.bin -nt -l tr -f /dev/shm/mic.wav )"
whispercpp
음성은 텍스트 엔진으로 음성 으로 전송되어 전사됩니다. 결과는 화면의 알림에 표시됩니다.
하지만 해당 줄을 파일에 배치하고 실행하면 다음과 같습니다.
#!/bin/bash
t2s && notify-send -u normal -t 10000 "$( whispercpp -m /home/****/Desktop/2022-10/whisper.cpp/models/ggml-small.bin -nt -l tr -f /dev/shm/mic.wav )"
exit 0
GUI 버튼만 실행하며, 버튼을 놓은 후 GUI가 종료되면 실행되지 않습니다.
notify-send -u normal -t 10000 "$( whispercpp -m /home/****/Desktop/2022-10/whisper.cpp/models/ggml-small.bin -nt -l tr -f /dev/shm/mic.wav )"
부분
내가 도대체 뭘 잘못하고있는 겁니까?
편집하다:
나는 또한 다음과 같이 시도했습니다.
#!/bin/bash
t2s
TEXT=$( whispercpp -m /home/****/Desktop/2022-10/whisper.cpp/models/ggml-small.bin -nt -l tr -f /dev/shm/mic.wav )"
notify-send -u normal -t 10000 $TEXT
아무것도 바뀌지 않았습니다.
편집하다:
쉘 내부와 관련이 있다는 것을 알았습니다.
- https://stackoverflow.com/questions/81520/how-to-suppress-terminating-message-after-killing-in-bash
- https://stackoverflow.com/questions/32551713/how-can-i-silence-the-terminating-message-when-my-command-is-killed-by-timeout
- https://unix.stackexchange.com/questions/65902/why-does-bash-show-terminating-after-killing-a-process
아직은 어떻게 극복해야 할지 모르겠어요.
답변1
다음 링크를 읽은 후:
ffmpeg
내에서 실행된 라인이 종료되면 GUI GUI button
이후 bash 쉘이 종료된다는 것을 이해했습니다 . 블록 내에서 t2s
채팅 SIGINT
과 SIGTERM
신호를 보내 문제를 trap
해결한 다음 나머지 명령을 그 안에 배치했습니다 t2s
.
#!/bin/bash
trap_with_arg() { # from https://stackoverflow.com/a/2183063/804678
local func="$1"; shift
for sig in "$@"; do
trap "$func $sig" "$sig"
done
}
stop() {
trap - SIGINT EXIT
printf '\n%s\n' "received $1, killing child processes"
notify-send -u normal -t 10000 "$(whispercpp -m /home/**/Desktop/2022-10/whisper.cpp/models/ggml-small.bin -nt -l tr -f /dev/shm/mic.wav )"
kill -s SIGINT 0
}
trap_with_arg 'stop' EXIT SIGINT SIGTERM SIGHUP
t2s
exit 0