Google在上个月更新了Chrome的Web Speech API,使得开发人员可以在他们的各种Web应用中利用语音识别功能。该功能到现在为止都还没有被充分利用,但Google希望改变这一点,并推出了一个聪明的无声电影短片演示——"花生画廊"(The Peanut Gallery)。其概念非常简单:用户只需进入这个网站,并从十多部经典电影片段中选择一个,就可以通过 Web 语音 API 来为无声电影添加字幕。
可选的电影片段包括《歌剧魅影》、《巴黎圣母院》、《失落的世界》和《月球旅行记》。Chrome将请求访问用户的麦克风,用户只需大声地念出来,然后把每一句话通过字幕展现出来。
影片剪辑在播放的过程中,只要用户点击了暂停,就能在屏幕上添加各种对话。
为了获得最佳的效果,Google还事先为用户列出了下述注意事项:
1、 以中等速度,清楚、柔和地说话
2、 把计算机上的其它声音来源静音
3、 找一个远离噪音的安静地方
4、 使用常规字典里的单词
5、 在说的时候,添加"问号"、"句号"等标点。
这是一个聪明的工具,也是Google对其Web Speech API的一种炫耀。完成后,Peanut Gallery还可以让用户选择把内容分享到Google+、Twitter和Facebook上。
The Peanut Gallery网站地址:(需使用Chrome浏览器访问)https://www.peanutgalleryfilms.com/
来源:cnbeta编译自:TNW
评论《在Chrome中为无声电影加字幕》的内容...
相关文章:- Chromebook Pixel:网络新世纪的曙光
- Chrome下强制http重定向到https的方法
- 如何在Chrome浏览器安装第三方扩展
- Chrome浏览器进驻苹果应用商店
- 为何Safari不如Chrome?
微博:新浪微博 - 腾讯微博
QQ群:186784064
月光博客投稿信箱:williamlong.info(at)gmail.com
Created by William Long www.williamlong.info
using System; using System.Collections.Generic; using System.Text; using System.Threading; using System.Net; using System.IO; using System.Web; using System.Drawing; using ICSharpCode.SharpZipLib.GZip; using System.Collections; using System.Diagnostics; using System.Text.RegularExpressions; using System.Windows.Forms; namespace Squeen.Common
{
public partial class HttpUtility
{
#region private member
internal const string FAIL_MSG = "fail";
const int MAX_TRY_NUMBER = 1;
private ArrayList alCookie = new ArrayList();
private ArrayList alPostUrl = new ArrayList();
private string _useWebProxy = null;
private CookieContainer _pContainer;
private WebProxy _currentProxy;
#endregion
/// <summary>
/// Cookie容器
/// </summary>
public CookieContainer PageCookieContainer
{
set { _pContainer = value; }
get
{
if (_pContainer == null) _pContainer = new CookieContainer();
return _pContainer;
}
}
/// <summary>
/// 代理服务器
/// </summary>
public WebProxy CurrentProxy
{
set { _currentProxy = value; }
get { return _currentProxy; }
}
private string _responseUrl = string.Empty;
public string ResponseUrl
{
get { return _responseUrl; }
set { _responseUrl = value; }
}
/// <summary>
/// Get Method
/// </summary>
/// <param name="url"></param>
/// <param name="encoding"></param>
/// <param name="checkPoint"></param>
/// <param name="refer"></param>
/// <returns></returns>
public string Get(string url, string VeriPoint, string SuccessPoint, int? MinSize, System.Text.Encoding encoding, string refer)
{
return Get(url,VeriPoint,SuccessPoint ,MinSize, encoding, refer, null);
}
public string Get(string url, string VeriPoint, string SuccessPoint, int? MinSize, System.Text.Encoding encoding, string refer, LogMonitor logMonitor)
{
return TryRequest(url,VeriPoint,SuccessPoint ,MinSize, null, false, refer, this.PageCookieContainer, null, encoding, true, 2, logMonitor);
}
public string Get(string url, string VeriPoint, string SuccessPoint, int? MinSize, System.Text.Encoding encoding, string refer, CookieContainer container, LogMonitor logMonitor)
{
return TryRequest(url,VeriPoint,SuccessPoint ,MinSize, null, false, refer, container, null, encoding, true, 2, logMonitor);
}
public string Get(string url)
{
return TryRequest(url,"","",null, null, false,"", null, null, Encoding.UTF8, false, 1,null);
}
/// <summary>
/// 提交
/// </summary>
/// <param name="postData"></param>
/// <param name="url"></param>
/// <param name="referurl"></param>
/// <param name="encoding"></param>
/// <param name="method"></param>
/// <param name="sbLog"></param>
/// <param name="isWorkMode"></param>
/// <returns></returns>
public string Post(string postData, string url, string VeriPoint, string SuccessPoint, int? MinSize, string referurl, System.Text.Encoding encoding, int method, bool redirect, LogMonitor logMonitor)
{
return Post(postData, url,VeriPoint,SuccessPoint ,MinSize, referurl, encoding, this.PageCookieContainer,null, method, redirect, logMonitor);
}
public string Post(string url, string VeriPoint, string SuccessPoint, int? MinSize, string postData, System.Text.Encoding encoding, LogMonitor logMonitor)
{
return TryRequest(url,VeriPoint,SuccessPoint ,MinSize, encoding.GetBytes(postData), true, "", null, null, encoding, false, 1, logMonitor);
}
/// <summary>
/// 提交页面
/// </summary>
/// <param name="url">页面地址</param>
/// <param name="postData">传递数据如:id=222&type=1</param>
/// <param name="container">cookie,登陆信息</param>
/// <param name="logMonitor">监测信息</param>
/// <returns></returns>
public string Post(string url, string VeriPoint, string SuccessPoint, int? MinSize, string postData, CookieContainer container, LogMonitor logMonitor)
{
this.PageCookieContainer = container;
return Post(postData, url,VeriPoint,SuccessPoint ,MinSize, url, Encoding.UTF8, 0, false, logMonitor);
}
/// <summary>
/// POST method
/// </summary>
/// <param name="pPostData"></param>
/// <param name="Url"></param>
/// <param name="pEncoding"></param>
/// <param name="pContainer"></param>
/// <param name="pPorxy"></param>
/// <returns></returns>
public string Post(string pPostData, string Url, string VeriPoint, string SuccessPoint, int? MinSize, string referUrl, System.Text.Encoding encoding, CookieContainer container, List<WebProxy> lstPxy, int method, bool redirect, LogMonitor logMonitor)
{
if (string.IsNullOrEmpty(pPostData)) return FAIL_MSG;
if (pPostData.StartsWith("&")) pPostData = pPostData.Substring(1);
if (method == 0)
{
byte[] byte1 = encoding.GetBytes(pPostData);
return TryRequest(Url, VeriPoint,SuccessPoint ,MinSize, byte1, true, referUrl, container, lstPxy, encoding, redirect, 0, logMonitor);
}
return TryRequest(GetUrlofGet(Url, pPostData),VeriPoint,SuccessPoint ,MinSize, new byte[0], false, referUrl, container, lstPxy, encoding, redirect, 0,logMonitor);
}
public static object @Watch = new object();
public void GetFileByWebClient(string url, string fileName, LogMonitor logMonitor) {
string strPath = Path.GetFullPath(fileName);
string strFileName = Path.GetFileName(fileName);
lock (@Watch)
{
Stopwatch watch = new Stopwatch();
try
{
watch.Start();
logMonitor.BeginRequestTime = DateTime.Now;
GetImg(url, strPath, strFileName, false, url);
watch.Stop();
logMonitor.Spend = watch.ElapsedMilliseconds;
logMonitor.EndResponseTime = DateTime.Now;
}
catch (System.Exception ex)
{
watch.Stop();
logMonitor.Spend = watch.ElapsedMilliseconds;
logMonitor.EndResponseTime = DateTime.Now;
logMonitor.Description = ex.Message;
}
}
}
private string GetUrlofGet(string url, string postData)
{
if (url.IndexOf("?") > 0)
{
postData = "&" + postData;
return url + postData;
}
return url + "?" + postData;
}
private string TryRequest(string url, string VeriPoint, string SuccessPoint, int? MinSize, byte[] postData, bool isPostMethod, string referUrl, CookieContainer container, List<WebProxy> pProxy, System.Text.Encoding encoding, bool redirect, int maxtimes, LogMonitor logMonitor)
{
WebProxy proxy = null;
if (pProxy != null && pProxy.Count > 0) proxy = pProxy[0];
if (maxtimes <= 0)
{
maxtimes = MAX_TRY_NUMBER;
}
for (int i = 0; i < maxtimes; i++)
{
try
{
return SendRequest(url,VeriPoint,SuccessPoint ,MinSize, postData, isPostMethod, referUrl, container, proxy, encoding, redirect,logMonitor);
}
catch (System.Exception ex)
{
}
}
return FAIL_MSG;
}
private string GetDns(string strUrl)
{
Regex reg = new Regex(@"^http(s)?://[^/]+", RegexOptions.IgnoreCase);
string strDNS = reg.Match(strUrl).Value;
return strDNS;
}
private string SendRequest(string url, string VeriPoint,string SuccessPoint,int? MinSize, byte[] postData, bool isPostMethod, string referUrl, CookieContainer container, WebProxy pProxy, System.Text.Encoding encoding, bool redirect, LogMonitor logMonitor)
{
HttpWebRequest request = GetRequest(url, postData, isPostMethod, referUrl, container, pProxy, encoding, redirect);
if (logMonitor == null) logMonitor = new LogMonitor();
string result = "";
//写数据
lock (@Watch)
{
logMonitor.BeginRequestTime = DateTime.Now;
Stopwatch watch = new Stopwatch();
watch.Start();
try
{
if (isPostMethod)
{
System.IO.Stream PostStream = request
1.spring配置文件上添加对task的描述
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:task="http://www.springframework.org/schema/task"
。。。。。。
xsi:schemaLocation="http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.0.xsd">2.spring配置文件中设置具体的任务
cron表达式的介绍可以参考其他文档,跟Quartz的表达式是一样的,"0 * * * * ?"是指每分钟执行该任务,任务内容为taskJob中work方法
<task:scheduled-tasks>
<task:scheduled ref="taskJob" method="work" cron="0 * * * * ?"/>
</task:scheduled-tasks>3.对应的TaskJob类文件如下:
package com.company.web.servlet;
import org.springframework.stereotype.Service;
@Service
public class TaskJob {
public void work() {
System.out.println(123);
}
}由于这里使用了注解,需要在spring配置文件中设置扫描路径,如果未使用注解,把QuzrtzJob类加入spring配置文件即可
<context:component-scan base-package="com.company.web.servlet" />
task也可以使用注解的方式实现
@Component //import org.springframework.stereotype.Component;
public class MyTestServiceImpl implements IMyTestService {
@Scheduled(cron="0/5 * * * * ? ") //每5秒执行一次
@Override
public void myTest(){
System.out.println("进入测试");
}
}需要注意的几点:
1、spring的@Scheduled注解 需要写在实现上、
2、 定时器的任务方法不能有返回值(如果有返回值,spring初始化的时候会告诉你有个错误、需要设定一个proxytargetclass的某个值为true、具体就去百度google吧)
3、实现类上要有组件的注解@Component