Aip.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: chendeben
  5. * Date: 2017/12/6
  6. * Time: 11:50
  7. */
  8. namespace PhpLife\App\Api\Controller;
  9. use PhpLife\App\Api\Controller;
  10. use PhpLife\Frame\Logger;
  11. use PhpLife\Library\AipOcr;
  12. use PhpLife\Library\AipSpeech;
  13. use PhpLife\Library\Postgres;
  14. use PhpLife\Library\Sentry;
  15. class Aip extends Controller
  16. {
  17. public function main()
  18. {
  19. $this->baidu();
  20. // Logger::setLog("cdb@meitu.com","test2",'sentry');
  21. die();
  22. // var_dump(Postgres::getInstance()->count("t_article"));
  23. // $data=Postgres::getInstance()->select('t_article');
  24. $data=Postgres::getInstance()->postgres->count('t_article');
  25. var_dump($data);
  26. }
  27. public function baidu(){
  28. $word=$this->getQuery()->string("q",'你好!');
  29. $appId = "10537047";
  30. $apiKey = "7OzniBlSCMEjEouv61Ayeu2K";
  31. $secretKey = "adG7sz1UHrjbep4VvfTN4xrdLFjf9Aws";
  32. $baiduAip = new AipOcr($appId, $apiKey, $secretKey);
  33. $result = $baiduAip->basicGeneral(file_get_contents('/www/xjy.png'));
  34. var_dump($result);
  35. }
  36. public function test($count){
  37. $prev = 0;
  38. $current = 1;
  39. for ($i = 0; $i < $count; ++$i) {
  40. $next = $prev + $current;
  41. $prev = $current;
  42. $current = $next;
  43. yield $prev;
  44. }
  45. }
  46. public function xrange($start,$end,$step=1){
  47. for ($i = $start; $i <= $end; $i += $step) {
  48. yield $i;
  49. }
  50. }
  51. }