小编Skr*_*ing的帖子

检测蓝牙耳机按钮按下

我在谷歌搜索过,但没有得到我想要的。

有没有办法检测耳机按钮按下?

我正在使用语音识别器从用户那里获取输入,它工作正常。它持续工作并等待特定单词激活,但我想使用蓝牙/任何带遥控器的耳机来通过按下特定按钮来激活它。

我遇到了他们说媒体应用程序只能播放/暂停/音量控制的答案。

macos cocoa

5
推荐指数
0
解决办法
158
查看次数

使用 ReactJS 和 Firebase 进行身份验证

我是 Web 开发的新手,并开始学习 ReactJS。

到目前为止,构建简单的 Web 应用程序没有问题。

现在我想使用 Firebase 进行身份验证。

我知道如何使用 Firebase 对用户进行身份验证,但我无法了解如何设计前端以限制对某些页面的访问。

以前,我使用 PHP 并在其中使用session变量并include包含 HTML 部分以显示给用户。

但我不知道如何使用 Firebase 在 ReactJS 中做到这一点。

初始和失败的方法:

我想更新this.state.loggedIn并使用它来显示组件。但这不是正确的方法,因为我将两个组件都发送给显示,我们可以使用 Chrome 中的 React 开发人员扩展轻松更改组件的状态。

这是我的主要 index.js 代码:

import React from 'react';
import ReactDOM from 'react-dom';
import Login from './components/Login/Login';
import Home from './components/Home/Home';
import fire from './components/Fire';


class App extends React.Component {

    constructor(props) {
        super(props);
        this.state = {
            loggedIn: false,
        };

        this.authListener = this.authListener.bind(this);

    }

    componentDidMount() {
        this.authListener();
    } …
Run Code Online (Sandbox Code Playgroud)

javascript authentication firebase reactjs firebase-authentication

5
推荐指数
1
解决办法
2807
查看次数

为什么"is_modulo"对于double和float来说是假的?

我写了一些代码来检查类型是否具有模数表示:

#include <iostream>
#include <limits>

using namespace std;

int main( )
{
    cout << "Whether float objects have a modulo representation: "
         << numeric_limits<float>::is_modulo << endl;
    cout << "Whether double objects have a modulo representation: "
         << numeric_limits<double>::is_modulo << endl;
}
Run Code Online (Sandbox Code Playgroud)

输出:

Whether float objects have a modulo representation: 0
Whether double objects have a modulo representation: 0
Run Code Online (Sandbox Code Playgroud)

但我们可以使用fmod()(from <math.h>)来找到float或的模数double.那么,is_modulo如果可以找到float或double的模数,为什么是false?

c++

4
推荐指数
1
解决办法
106
查看次数

NSWindow快速圆角

我想要一个圆角的窗户.但是我在每个角落都有一个白点.

码:

let effect = NSVisualEffectView(frame: NSRect(x: 0, y: 0, width: 0, height: 0))
effect.blendingMode = .behindWindow
effect.state = .active
effect.material = .dark
effect.wantsLayer = true
effect.layer?.cornerRadius = 15.0
window.contentView = effect
window.titlebarAppearsTransparent = true
window.titleVisibility = .hidden
Run Code Online (Sandbox Code Playgroud)

输出:

在此输入图像描述

如何摆脱角落里的那些白点?

macos cocoa swift

4
推荐指数
1
解决办法
1299
查看次数

禁用CMUSphinx4中的控制台乱

我正在尝试CMUSphinx,但我很难过.我已经在Eclipse中包含了jar coredatajar,我从这里下载了它

我试着像教程中提到的那样进行实时语音识别,但是当我尝试运行它时,控制台上充满了某些类似的错误The dictionary is missing a phonetic transcription for the word '....'.

码:

import edu.cmu.sphinx.api.Configuration;
import edu.cmu.sphinx.api.LiveSpeechRecognizer;
import edu.cmu.sphinx.api.SpeechResult;

public class Hello {       

   public static void main(String[] args) throws Exception {
    Configuration configuration = new Configuration();


    configuration.setAcousticModelPath("resource:/edu/cmu/sphinx/models/en-us/en-us");

    configuration.setDictionaryPath("resource:/edu/cmu/sphinx/models/en-us/cmudict-en-us.dict");

    configuration.setLanguageModelPath("resource:/edu/cmu/sphinx/models/en-us/en-us.lm.bin");
    LiveSpeechRecognizer recognizer = new LiveSpeechRecognizer(configuration);

    while(true)
    {
    System.out.println("Start speaking...");
    recognizer.startRecognition(true);
    SpeechResult result = recognizer.getResult();
    System.out.println("result: "+result.getHypothesis());

    recognizer.stopRecognition();
    }

}
}
Run Code Online (Sandbox Code Playgroud)

安慰:

23:15:07.552 INFO unitManager          CI Unit: *+NSN+
23:15:07.556 INFO unitManager …
Run Code Online (Sandbox Code Playgroud)

java sphinx4 cmusphinx

3
推荐指数
1
解决办法
821
查看次数

无法读取 Firebase 函数中未定义错误的属性 https

我正在关注有关用于服务器端反应渲染的云函数的 youtube firebase 官方教程

(顺便说一下,我按照视频的确切目录结构进行操作。)

但是每当我尝试提供服务时都会收到错误消息:

i  functions: Preparing to emulate functions.
?  hosting: Port 5000 is not available. Trying another port...
i  hosting: Serving hosting files from: dev
?  hosting: Local server: http://localhost:5004

?  functions: Failed to load functions source code. Ensure that you have the latest SDK by running npm i --save firebase-functions inside the functions directory.
?  functions: Error from emulator. Error occurred while parsing your function triggers.

TypeError: Cannot read property 'https' …
Run Code Online (Sandbox Code Playgroud)

javascript firebase reactjs google-cloud-functions

0
推荐指数
1
解决办法
1394
查看次数

C - int*p是什么; P = 15; 呢?

这两个代码示例有什么区别?当我打印变量时p,它会打印指定的值,如下所示.

int *p;
p = 51;
printf("%d",p);
Run Code Online (Sandbox Code Playgroud)

产量:51

当我尝试分配时p=15,我是否在ram中将内存地址设置为"15"作为指针的指针p?当我尝试添加int c = 5 +p;它时输出为71.我为什么要71岁?

我认为内存地址"15"可以存储操作系统,程序等的任何信息.但它确切存储int精确.虽然我改变了p = 150;它给出的价值 int.怎么可能?引擎盖下发生了什么?!我真的不明白.

c

-4
推荐指数
1
解决办法
167
查看次数