语音在线听书demo:http://blog.csdn.net/ls0609/article/details/71519203
语音记账demo:http://blog.csdn.net/ls0609/article/details/72765789
基于JavaScript用olamisdk实现web端语音识别语义理解(speex压缩)
http://blog.csdn.net/ls0609/article/details/73920229
在物联网时代,有时需要在局域网中快速搜索设备,本片讲述cling搜索的一个例子。
UPnP全名是Universal Plug and Play,主要是微软在推行的一个标准。简单的来说,UPnP 最大的愿景就是希望任何设备只要一接上网络,所有在网络上的设备马上就能知道有新设备加入,这些设备彼此之间能互相沟通,更能直接使用或控制它,一切都不需要设定,完全的Plug and Play。
cling就是采用了这个协议来进行服务端的注册和客户端的扫描发现。
服务端注册后,客户端扫描大概时间在2-5秒,就像windows平台局域网刷新群组内成员一样迅速,如下图扫描结果:
首先看服务端如何注册
public class MainActivity extends Activity implements PropertyChangeListener {
// DOC:CLASS
private static final Logger log = Logger.getLogger(MainActivity.class.getName());
// DOC:SERVICE_BINDING
private AndroidUpnpService upnpService;
private UDN udn = new UDN(UUID.randomUUID()); // TODO: Not stable!
private ServiceConnection serviceConnection = new ServiceConnection() {
public void onServiceConnected(ComponentName className, IBinder service) {
upnpService = (AndroidUpnpService) service;
LocalService<SwitchPower> switchPowerService = getSwitchPowerService();
// Register the device when this activity binds to the service for the first time
if (switchPowerService == null) {
try {
LocalDevice binaryLightDevice = createDevice();
Toast.makeText(MainActivity.this, R.string.registeringDevice,
Toast.LENGTH_SHORT).show();
upnpService.getRegistry().addDevice(binaryLightDevice);
switchPowerService = getSwitchPowerService();
} catch (Exception ex) {
log.log(Level.SEVERE, "Creating BinaryLight device failed", ex);
Toast.makeText(MainActivity.this, R.string.createDeviceFailed,
Toast.LENGTH_SHORT).show();
return;
}
}
// Obtain the state of the power switch and update the UI
setLightbulb(switchPowerService.getManager().getImplementation().getStatus());
// Start monitoring the power switch
switchPowerService.getManager().getImplementation().getPropertyChangeSupport()
.addPropertyChangeListener(MainActivity.this);
}
public void onServiceDisconnected(ComponentName className) {
upnpService = null;
}
};
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// DOC:LOGGING
// Fix the logging integration between java.util.logging and Android internal logging
// org.seamless.util.logging.LoggingUtil.resetRootHandler(
// new FixedAndroidLogHandler()
// );
// Logger.getLogger("org.fourthline.cling").setLevel(Level.FINEST);
// DOC:LOGGING
setContentView(R.layout.light);
getApplicationContext().bindService(
new Intent(this, AndroidUpnpServiceImpl.class),
serviceConnection,
Context.BIND_AUTO_CREATE
);
}
@Override
protected void onDestroy() {
super.onDestroy();
// Stop monitoring the power switch
LocalService<SwitchPower> switchPowerService = getSwitchPowerService();
if (switchPowerService != null)
switchPowerService.getManager().getImplementation().getPropertyChangeSupport()
.removePropertyChangeListener(this);
getApplicationContext().unbindService(serviceConnection);
}
protected LocalService<SwitchPower> getSwitchPowerService() {
if (upnpService == null)
return</