我在安装了pyAudio的Python 2.7中运行以下代码.
import speech_recognition as sr
r = sr.Recognizer()
with sr.Microphone() as source: # use the default microphone as the audio source
audio = r.listen(source) # listen for the first phrase and extract it into audio data
try:
print("You said " + r.recognize(audio)) # recognize speech using Google Speech Recognition
except LookupError: # speech is unintelligible
print("Could not understand audio")
Run Code Online (Sandbox Code Playgroud)
输出指示闪烁.而已.请帮助,因为我是新手.
每当尝试更改时,我都试图将JavaScript变量的值从ui.R发送到Server.R。用户单击链接时,将警告其href值。到这里为止一切正常。链接的形式
<a href="something.com" onclick=\"clickFunction(this.href); return false;\" target=\"_blank\">Sample link </a>
Run Code Online (Sandbox Code Playgroud)
现在,href值存储link在ui.R中的变量中。我正在使用Shiny.onInputChange函数将链接的值发送到server.R。
但是server.R中的观察功能没有给我任何价值。请告诉我如何通过使用观察功能或其他任何可能的方式来执行此操作。
用户界面
library(shiny)
shinyUI(fluidPage(
tags$script(HTML("
function clickFunction(link){
alert(link);
Shiny.onInputChange(\"linkClicked\",link);
}
"))
//rest of the code which is not related
)
Run Code Online (Sandbox Code Playgroud)
服务器
library(shiny)
shinyServer(function(input, output) {
observe({
input$linkClicked
print(input$linkClicked)
})
})
Run Code Online (Sandbox Code Playgroud)