| 47 | | let pid,ret = |
| 48 | | dlog#f 3 "Synthetizing %S to %S" s local ; |
| 49 | | let pid = flush_all () ; fork () in |
| 50 | | if pid = 0 then ( |
| 51 | | try |
| 52 | | Sys.set_signal |
| 53 | | Sys.sigalrm (Sys.Signal_handle (fun _ -> core_exit 2)) ; |
| 54 | | assert (0 = Unix.alarm (int_of_float (maxtime -. time ()))) ; |
| 55 | | if voice <> "" then |
| 56 | | execv cmd [| cmd;s;local;voice |] |
| 57 | | else |
| 58 | | execv cmd [| cmd;s;local |] |
| 59 | | with |
| 60 | | | _ -> core_exit 1 |
| 61 | | ) else |
| 62 | | waitpid [] pid |
| 63 | | in |
| 64 | | if ret = Unix.WEXITED 0 then ( |
| 65 | | [Request.indicator ~temporary:true local] |
| 66 | | ) else ( |
| 67 | | log "Speech synthesis failed !" ; |
| 68 | | ( try Unix.unlink local with _ -> () ) ; |
| 69 | | [] |
| 70 | | ) |
| | 50 | try |
| | 51 | let pid,ret = |
| | 52 | dlog#f 3 "Synthetizing %S to %S" s local ; |
| | 53 | let pid = flush_all () ; fork () in |
| | 54 | if pid = 0 then begin |
| | 55 | try |
| | 56 | Sys.set_signal |
| | 57 | Sys.sigalrm (Sys.Signal_handle (fun _ -> core_exit 2)) ; |
| | 58 | assert (0 = Unix.alarm (int_of_float (maxtime -. time ()))) ; |
| | 59 | if voice <> "" then |
| | 60 | execv cmd [| cmd;s;local;voice |] |
| | 61 | else |
| | 62 | execv cmd [| cmd;s;local |] |
| | 63 | with |
| | 64 | | _ -> core_exit 1 |
| | 65 | end else |
| | 66 | waitpid [] pid |
| | 67 | in |
| | 68 | if ret = Unix.WEXITED 0 then |
| | 69 | [Request.indicator ~temporary:true local] |
| | 70 | else |
| | 71 | failwith "synthesis script returned an error" |
| | 72 | with |
| | 73 | | e -> |
| | 74 | (* This could for example be ENOMEM raised by Unix.fork. *) |
| | 75 | dlog#f 3 |
| | 76 | "Failed to synthetize speech: %s!" |
| | 77 | (match e with Failure s -> s | _ -> Printexc.to_string e) ; |
| | 78 | log "Speech synthesis failed!" ; |
| | 79 | (try Unix.unlink local with _ -> ()) ; |
| | 80 | [] |