我在Ubuntu 22.04平台上。我在c#中做了一个简单的按钮GUI,名为t2s,并将它放在~/.local/bin中,它的路径被添加到PATH环境变量中。当我按下按钮时,它正在录制从麦克风到临时文件的声音。当我释放按钮GUI退出。我运行了以下行,它在终端中运行得很好:
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什么都没变。
编辑:
我注意到这与壳内件有关。
我还是不知道怎么克服它。
发布于 2022-11-11 10:32:26
阅读以下链接后:
我理解在ffmpeg中执行的GUI button行的终止会导致bash在t2s GUI之后终止。我通过在一个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 0https://askubuntu.com/questions/1439782
复制相似问题